On 01/26/2010 01:02 AM, Nick Sabalausky wrote:
"strtr"<st...@spam.com>  wrote in message
news:hjd6t1$be...@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.


I think in should work for keys in an associative array and for values in a regular array.

This is how it works in python.

Reply via email to