develooper Front page | perl.beginners | Postings from September 2009

Re: !! notation

Thread Previous | Thread Next
Chas. Owens
September 9, 2009 08:25
Re: !! notation
Message ID:
On Wed, Sep 9, 2009 at 09:46, Dermot<> wrote:
> my $var = !! $class->method;

This is really

my $var = ! ( ! $class->method );

People do this to create a boolean like value.  Perl has many false
values and many true values:

False: (), "", "0", 0, 0.0, and undef
True:  any value that explicitly named above

Occasionally it is nice to have just one false and one true to worry
about.  Double negation will always returns either an empty string or
1 depending on whether the value was false or true.

Chas. Owens
The most important skill a programmer can have is the ability to read.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About