boolean over multiple variables
Nick Sabalausky
a at a.a
Mon Jan 25 16:02:24 PST 2010
"strtr" <strtr at spam.com> wrote in message
news:hjd6t1$beh$1 at digitalmars.com...
> This may be is a very basic question, but is there a way to let me omit a
> repeating variable when doing multiple boolean operations?
>
> if ( var == a || var == b || var == c || var == d)
> if ( var == (a || b || c || d) )
I do this:
-------------------------
import tango.core.Array;
void main()
{
if( [3, 5, 6, 12].contains(7) )
{
}
}
-------------------------
There's probably a phobos equivilent, too.
Alhough, I would much prefer what other people mentioned about having "in"
refer to the values of a collection rather than the keys. But I've been
using the above as a substitute.
More information about the Digitalmars-d-learn
mailing list