in reply to Re^2: 'return:' instead of 'return'
in thread 'return:' instead of 'return'
I had expected something more like the behaviour from this:Are you suggesting you didn't even try to run:Where it's not the 3 that gets returned, rather it's a coderef to an anonymous subroutine.sub fn { sub { 3 } }
and see what it returns? Printing the return value of fn would have instantly revealed fn had returned '3', and not a code reference.sub fn { return: 3 }
BTW, is 'return 3;' a statement?Most certainly. What else could it be? It's not some pretty decorations.
If so, is it then a special exception to the rule 'blocks return the value of the last statement executed'It's a statement. But it's not a block.
is the value of 'return 3' equal to 3 ?
So, what do you think?sub foo {return 3;} print foo(); __END__ 3
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: 'return:' instead of 'return'
by Boldra (Curate) on Jun 12, 2009 at 10:41 UTC | |
by jethro (Monsignor) on Jun 12, 2009 at 11:04 UTC | |
by Boldra (Curate) on Jun 12, 2009 at 11:58 UTC | |
by jethro (Monsignor) on Jun 12, 2009 at 13:34 UTC | |
by JavaFan (Canon) on Jun 12, 2009 at 12:10 UTC | |
by Boldra (Curate) on Jun 12, 2009 at 12:21 UTC | |
by Corion (Patriarch) on Jun 12, 2009 at 12:31 UTC | |
by Zen (Deacon) on Jun 12, 2009 at 15:49 UTC | |
by JavaFan (Canon) on Jun 12, 2009 at 16:04 UTC |