in reply to Burned by precedence rules
I like to use and and not in my code, but as JavaFan pointed out, they have a lower precedence. So I find it best to address this by taking the same approach. I always use a if operator and usually have at least 2 return calls. I find it is clearer what I intended to return as a valid value.
sub done { my $self = shift; return 1 if not $self->foo and not $self->bar; return; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Burned by precedence rules
by GrandFather (Saint) on Dec 26, 2008 at 04:50 UTC | |
by tilly (Archbishop) on Dec 26, 2008 at 05:00 UTC | |
by GrandFather (Saint) on Dec 26, 2008 at 20:45 UTC | |
by tilly (Archbishop) on Dec 27, 2008 at 05:59 UTC | |
by gwadej (Chaplain) on Dec 26, 2008 at 13:25 UTC | |
by tye (Sage) on Dec 27, 2008 at 06:53 UTC | |
by gwadej (Chaplain) on Dec 28, 2008 at 20:53 UTC | |
by tilly (Archbishop) on Dec 26, 2008 at 15:20 UTC | |
by gwadej (Chaplain) on Dec 26, 2008 at 15:39 UTC | |
by Marshall (Canon) on Dec 26, 2008 at 18:45 UTC |