in reply to Re: Perl Idioms Explained - !!expr
in thread Perl Idioms Explained - !!expr
Depending on context this will return different things, whereas !!expr will always return a boolean value.return grep { $_ eq $_[0] } @_[ 1 .. $#_ ];
This will return the number of elements returned by grep as opposed to !!expr which, again, will return a boolean value.return ~~grep { $_ eq $_[0] } @_[ 1 .. $#_ ];
Of course both of the above are valid in appropriate situations, but if you just want a boolean value then !!expr is an appropriate idiomatic solution.
HTH
_________
broquaint
|
---|
In Section
Tutorials