On 12/16/2013 10:47 PM, Brad Anderson wrote:
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;
}


I must say that:

     if (val.between(3, 10))

sure is a lot easier to understand at a glance than:

     if (val >= 3 && val <= 10)
...

if (3 <= val && val <= 10)

is similarly easy to understand at a glance as the former. (Its drawback compared to that is that often a temporary variable will be required to be introduced in order to avoid recomputation.)

Reply via email to