My question is one that I have wondered about for sometime but never pursued out of lack of time. However, I am very curious now to learn how I could do this if at all.
The following code attempt fails:
Obviously, I had to declare precedence so that the intperpretter wouldn't get confused as to what to compare first then next , but, this still doesn't work. I've tried various other syntactical tweaks in the condition as well but haven't been able to find one that works. I know that you could and or && this but I would like to avoid that if possible.perl -e ' $a = 5; $b = 5; $c = 5; if ( ($a == $b) == $c ) { print "They are the same\n"; } else { print "They are not the same\n"; } '
I am thinking that this kind of operation would make it very easy to see if a number of variables all equal the same value which could be done in one condition without extra operators or repeating the lvalue more than once.if ( $a == $b and $a == $c ) { print "true\n"; } else { print "not true"; }
_
_
_
_
_
_
_
_
_
_
- Jim
Insert clever comment here...
In reply to Can If-then conditions do ($a = $b = $c) type expressions? by snafu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |