in reply to Re: Re: Can If-then conditions do ($a = $b = $c) type expressions?
in thread Can If-then conditions do ($a = $b = $c) type expressions?
if ( ($var1 == $var2) == $var3 ) Would be the same as: if ( $var1 == $var2 && $var1 == $var3 ) { Wouldn't it?
It wouldn't. You can think of "==" as if it were a normal function (and in Perl 6 it will be), that returns true or false. (both are represented internally by something special, and they are both numeric and string. In string context, true is "1" and false is "", in numeric context true is 1 and false is 0)
So, let's read it as:
The first == returns a boolean value, which is put into numerical context because of the other ==. That one compares $var3 to the value returned (0 or 1), so the entire expression is true if:if ( ==( ==($var1, $var2), $var3 ) ) {
- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: Re: Can If-then conditions do ($a = $b = $c) type expressions?
by snafu (Chaplain) on Apr 29, 2002 at 18:49 UTC |