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
In reply to Re^3: 'return:' instead of 'return'
by JavaFan
in thread 'return:' instead of 'return'
by Boldra
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |