if (a.among("struct", "class", "union")) { ... }
if (b.between(1, 100)) { ... }

Is between inclusive or not of the endpoints?

After quite a bit of thought, I think inclusive is the right way.

Then there's no way to specify an empty interval. I suppose with "between" that would not be relevant.

Perhaps b.between(1, 0) would always return false.

However I'd use different names: among=>isOneOf, between=>isInRange. I would also define another function inRange that ensures, rather than tests, that a value is in range:

string userInput = "-7";
int cleanInput = inRange(parse!int(userInput), 1, 100);

Reply via email to