Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
Can you have a ternary in 'return'?my $flag = 'yes'; my $return_value = test($flag); # return 'yes' $flag = ''; $return_value = test($flag); # return 'none' sub test() { my $value = shift; return $value ? $value : 'none'; # is the above line valid? }
Thank you :)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Return value in ternary
by ikegami (Patriarch) on Mar 29, 2010 at 16:33 UTC | |
Re: Return value in ternary
by JavaFan (Canon) on Mar 29, 2010 at 16:37 UTC | |
Re: Return value in ternary
by toolic (Bishop) on Mar 29, 2010 at 16:16 UTC | |
Re: Return value in ternary
by ramlight (Friar) on Mar 29, 2010 at 16:13 UTC | |
Re: Return value in ternary
by Anonymous Monk on Mar 30, 2010 at 14:18 UTC |