On Monday, 16 December 2013 at 20:38:52 UTC, Andrei Alexandrescu
wrote:
bool between(T, U1, U2)(T v, U1 lo, U2 hi)
{
return v >= lo && v <= hi;
}
uint among(T, Us...)(T v, Us vals)
{
foreach (i, U; Us)
{
if (v == vals[i]) return i + 1;
}
return 0;
}
Add?
Andrei
I don't know why we can do this instead:
if(foo in ["alpha", "beta", "delta"] ) {
}
basically have an opIn operator x in y -> y.opIn(x)
U* opIn(T, U)(T key)
can define in runtime for arrays, and allow custom ones to be
defines
and
if(1 < x <= 10) {
}
I remember this being shot down before...
Both of these are easier to read, and are more natural. They
also cover more cases.