Larry Wall writes:

> On Wed, Nov 19, 2003 at 08:08:49AM +1100, Damian Conway wrote:
> 
> : Michael Lazzaro wrote:
> : 
> : >    return if $a { $a }
> : 
> : Means:
> : 
> :    if ($a) { return $a } else { return undef }
> 
> No, it's a syntax error.  You must write
> 
>     return do { if $a { $a } }
> 
> to mean that.  At least in my version of Perl 6.  AIFIYP.

Excellent!  Larry, thank you for being here and enforcing sanity!

The above scared me, so I'm most glad to hear it won't be in the
language.  Apart from looking confusingly similar to much more common
statements, there already seem to be ample ways of doing this,
including:

  return $a || undef;

or, more generally if actually the two C<$a>s are not the same:

  return $a ?? $b :: undef;

Smylers

Reply via email to