boolean over multiple variables
Robert Clipsham
robert at octarineparrot.com
Tue Jan 26 07:43:11 PST 2010
On 22/01/10 21:55, strtr wrote:
> 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) )
/**
* Untested code, it works something like this though
* Find tools at:
* http://dsource.org/projects/scrapple/browser/trunk/tools/tools
*/
import tools.base;
void main()
{
T var, a, b, c, d;
...
if ( var == a /or/ b /or/ c /or/ d )
{
/**
* The same as:
* ----
* if ( var == a || var == b || var == c || var == d)
* {
* ...
* }
*/
}
}
More information about the Digitalmars-d-learn
mailing list