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

Re: !! notation

Thread Previous | Thread Next
From:
Chas. Owens
Date:
September 9, 2009 08:25
Subject:
Re: !! notation
Message ID:
58ce48dc0909090824v6e2463e2r295b5caa020c887c@mail.gmail.com
On Wed, Sep 9, 2009 at 09:46, Dermot<paikkos@googlemail.com> wrote:
snip
> my $var = !! $class->method;
snip

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
wonkden.net
The most important skill a programmer can have is the ability to read.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About