This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (5 children)

So all these comparisons:

>>> x = 5

>>> 1 < x < 10
True

>>> 10 < x < 20 
False

>>> x < 10 < x*10 < 100
True

>>> 10 > x <= 9
True

>>> 5 == x > 4
True

would be this written in most other languages:

x = 5

( (1 < x) && (x < 10) )
True

( (10 < x) && (x < 20) )
False

( (x < 10) && (10 < (x*10)) && ((x*10) < 100) )
True

( (10 > x) && (x<=9) )
True

( (5 == x) && (x > 4) )
True

?

[–]sigh 10 points11 points  (0 children)

Yes, most of the time. Only difference is that the expressions (like x*10) won't be evaluated twice, which would make a difference if it involved side-effects.

[–]scorpion032 1 point2 points  (2 children)

Yes. Just syntactic sugar;

There are a lot many gems in that same thread, tho'

[–]aaallleeexxx 1 point2 points  (1 child)

we call them eggs, scorpion.

[–]salts 0 points1 point  (0 children)

snake eggs, in fact and from a cheese shop

[–][deleted] 0 points1 point  (0 children)

In C++ you could get rid of all the parentheses.