in reply to Re^4: map in void context
in thread map in void context
It's not really returning "true", it's returning the value on the right side of the assignment.
my $x = 2; print "\$x is '$x'\n"; if ( $x = 0 ) { print "\$x = 0 is true\n"; } else { print "\$x = 0 is false\n"; } print "\$x is '$x'\n"; __END__ $x is '2' $x = 0 is false $x is '0'
This behavior is why you can say "$x = $y = $foo" and set both $x and $y to whatever is in $foo.
If you consider the "effect" of assignment to be returning the value of the right hand side, then perhaps changing the value of the variable is a side effect. I don't see it that way, however.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: map in void context
by ysth (Canon) on Dec 22, 2008 at 23:03 UTC | |
|
Re^6: map in void context
by pat_mc (Pilgrim) on Dec 21, 2008 at 21:02 UTC | |
by ikegami (Patriarch) on Dec 21, 2008 at 21:10 UTC | |
by pat_mc (Pilgrim) on Dec 22, 2008 at 09:09 UTC | |
by tilly (Archbishop) on Dec 22, 2008 at 09:17 UTC | |
by ikegami (Patriarch) on Dec 22, 2008 at 13:29 UTC | |
by pat_mc (Pilgrim) on Dec 22, 2008 at 23:47 UTC |