Dual conditions in D and Python
Dennis Ritchie via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu May 21 16:14:45 PDT 2015
On Thursday, 21 May 2015 at 21:35:22 UTC, Ali Çehreli wrote:
> We're almost there. :)
>
> bool is_between(T0, T1, T2)(T0 what, T1 min, T2 max)
> {
> return (what >= min) && (what <= max);
> }
>
> void main()
> {
> if (5.is_between(4, 6)) {
> // ...
> }
> }
>
> Ali
A condition is that if, for example, that? :)
if (5 > 2 > -9 > -13 < 10 == 10 < 21 != 45):
print("OK")
-----
http://rextester.com/JSC75231
import std.stdio;
void main()
{
if (5 > 2 &&
2 > -9 &&
-9 > -13 &&
-13 < 10 &&
10 == 10 &&
10 < 21 &&
21 != 45)
writeln("OK");
}
-----
http://rextester.com/AZFL70044
More information about the Digitalmars-d-learn
mailing list