in reply to Re^3: "last expression" quiz
in thread "last expression" quiz
Well, if works in that it returns the result of the last expression evaluated. It seems that's what looping constructs should do too. Wouldn't it make sense for this sub x { $_ for 10 } to return 10?Not really. If you're asking my opinion I'd say it should be an error if the sub is called in anything other than a void context. Note the following are also compilation errors...
You're not arguing that they shouldn't be, are you?my $what = (if(1){print "true"}else{print "false"}); sub foo { return (for (1..3) { print $_ }); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: "last expression" quiz
by sauoq (Abbot) on Oct 20, 2005 at 16:07 UTC | |
by Anonymous Monk on Oct 20, 2005 at 17:15 UTC |