Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I have a style question about return statements for small subs. Which of these three do you prefer, and why:
# 1: sub is_connected { return 1 if shift->is_writable } # 2: sub is_connected { return shift->is_writable } # or 3: sub is_connected { return shift->is_writable ? 1 : 0 # or undef, etc. }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Style question on conditional return statements:
by VSarkiss (Monsignor) on Oct 06, 2006 at 18:58 UTC | |
|
Re: Style question on conditional return statements:
by shmem (Chancellor) on Oct 06, 2006 at 17:57 UTC | |
|
Re: Style question on conditional return statements:
by jdporter (Paladin) on Oct 06, 2006 at 17:58 UTC | |
|
Re: Style question on conditional return statements:
by wojtyk (Friar) on Oct 06, 2006 at 18:14 UTC |