in reply to Re^2: reset particular variable
in thread reset particular variable
If you have a subroutine and you want to return "nothing", meaning not "undef", not "zero", I mean absolutely "nothing", what do you do?
This little gem, is on page 136 of "Effective Perl". It passes without even a comment!! Whoa!
Lets say that we have:
@output = map{zoomy_function}@input;
Map{} is a critter that processes each @input and spews out an @output (map{} is a transformation operator).
But, what would happen if for example the zoomy_function within map{} decides that it wants to "throw a value away". How do you do that? In Perl you can't even just exit a sub. The value of the last statement in a Perl sub is gonna get returned. What is that return value gonna be? "undef","0","-1"?
In Perl, you can return (), which means that NOTHING is returned! Something can just come into the func and no result ever comes out. The "black hole" of map().
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: reset particular variable
by AnomalousMonk (Archbishop) on Aug 19, 2009 at 17:52 UTC | |
by Marshall (Canon) on Aug 21, 2009 at 13:42 UTC | |
by AnomalousMonk (Archbishop) on Aug 21, 2009 at 16:21 UTC | |
by Marshall (Canon) on Aug 21, 2009 at 23:31 UTC | |
by Anonymous Monk on Aug 22, 2009 at 00:55 UTC | |
by Anonymous Monk on Aug 21, 2009 at 13:56 UTC | |
by Marshall (Canon) on Aug 21, 2009 at 15:09 UTC | |
by Anonymous Monk on Aug 22, 2009 at 00:39 UTC |