I think BrowserUk's point was on functions that don't return a value. I was assuming that in my post o/w I need to use the ternerary operator to catch it. Well one might argue that it is not always required to trap the return value but I feel if the funcion returns something then it is worth something
I still like the otherwise idea coz it makes the code more english like. Nothing more, nothing less. :) I cannot argue with BrowserUk on the equivalence of the code! :)They do the same thing!
| [reply] [Watch: Dir/Any] |
In Perl, all functions return a value unless normal processing is interrupted. The latter would include functions that die or exit.
| [reply] [Watch: Dir/Any] |
Thanks for the correction tilly! I should have known better. Agreed all functions return a value unless called in a void context!!!
When i started to play around with BrowserUk's statement on functions that return a value (with explicit return in my case) I realized i did not have that in mind when i wrote for the otherwise idea... So did not reply back saying it will fail under that instance coz i am not using the return value either in my code. What i forgot in the process was that subs implicitly return the last expression evaluated and the problem of returning false will execute both functions even if an explicit return in not used
I guess after reading jdporter's post and your question about functions returning false values, I guess it makes me feel otherwise will be a good feature if one want to write such conditional statements
I know it is too late in the game to think about such additions but it is nice to discuss!
-SK
| [reply] [Watch: Dir/Any] |
Obviously, if there was any chance of that it would have to be
$cond and doX,1 or doY;
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
| [reply] [Watch: Dir/Any] [d/l] |