in reply to Re: ||= oddity
in thread ||= oddity
A list is a sequence of expressions. How context propagates into that list has been the subject of much discussion. Here's a conversation piece:
sub wa { my $place = shift @_; my $context = wantarray ? 'list' : defined wantarray ? 'scalar' : 'void'; warn "'$context' context at '$place'\n"; } my $x ||= (wa('oe1'),wa('oe2'),wa('oe3')); print "\n"; my $y = (wa('e1'),wa('e2'),wa('e3')); print "\n"; my $z = sub { (wa('s1'),wa('s2'),wa('s3')) }->(); __END__ 'void' context at 'oe1' 'void' context at 'oe2' 'scalar' context at 'oe3' 'void' context at 'e1' 'void' context at 'e2' 'scalar' context at 'e3' 'scalar' context at 's1' 'scalar' context at 's2' 'scalar' context at 's3'
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: ||= oddity
by ruzam (Curate) on May 29, 2008 at 13:47 UTC | |
Re^3: ||= oddity
by ikegami (Patriarch) on Jun 24, 2008 at 20:22 UTC |