in reply to Re: return if defined
in thread return if defined
Clever, but maybe a little too clever.
This isn't the clearest construct in the world to begin with, and it especially has the potential to be confusing if the code within the do block is long. In that case, the last statement of the block is implicitly returned by the block and used as the return value, but it is a long way from the return statement itself.
You could do the exact same thing a lot more clearly just by using a subroutine.
sub my_find_or_create { # ... return $self->find_by_something(@args) // $self->create_new(@args); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: return if defined
by AnomalousMonk (Archbishop) on Dec 20, 2012 at 13:42 UTC |