in reply to How to deal with undefined returned variables.
knight makes a good point. Fortunately, in Perl 6, there will be a defaulting operator to simplify this very problem.
A binary // operator is the defaulting operator.Perl 6 should be such fun!
That is:is short for:$a // $bexcept that the left side is evaluated only once. It will work on arrays and hashes as well as scalars. It also has a corresponding assignment operator, which only does the assignment if the left side is undefined:defined($a) ?? $a :: $b$pi //= 3;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Answer: How to deal with undefined returned variables.
by rinceWind (Monsignor) on Mar 06, 2002 at 17:00 UTC |
In Section
Seekers of Perl Wisdom