in reply to Re^3: Condensing code...golfing with push and return
in thread Condensing code...golfing with push and return
No, use the proper return type for the proper function type. If you return an empty list for false, then you'll be tripped up by something as simple as:
If your function returns lists, then an empty list is likely the correct thing to return for "false". If your function never returns lists, then I'd have it return a false scalar value not an empty list.my %hash= ( this => GetThis(), foo => 'bar', baz => 'biff', ); # Which results in: # $hash{this} eq "foo" # ! exists $hash{foo} # $hash{bar} eq 'baz' # ! exists $hash{baz} # exists $hash{biff}
BTW, my favorite false value is !1 which is a lot like '' except that it won't give a warning if used in a numeric context. (It is what Perl's own functions return for "false but not undefined".)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Condensing code...golfing with push and return (mixed blessing)
by Aristotle (Chancellor) on Oct 10, 2003 at 22:25 UTC |