develooper Front page | perl.perl5.porters | Postings from February 2000

[ID 20000206.002] UNIVERSAL::can reports that undef is an object?

Thread Next
From:
Sean M. Burke
Date:
February 6, 2000 17:26
Subject:
[ID 20000206.002] UNIVERSAL::can reports that undef is an object?
Message ID:
200002070122.RAA22777@stonehenge.netadventure.net
Each of these
  $x = 123;    print UNIVERSAL::isa($x, "UNIVERSAL")  ? 'T' : 'F';
  $x = 'fish'; print UNIVERSAL::isa($x, "UNIVERSAL")  ? 'T' : 'F';
  $x = undef;  print UNIVERSAL::isa($x, "Stuff"    )  ? 'T' : 'F';
do print 'F', as expected.

But this
  $x = undef;  print UNIVERSAL::isa($x, "UNIVERSAL")  ? 'T' : 'F';
prints 'T'.

UNIVERSAL::isa ( VAL, TYPE )
 isa returns true if the first argument is a reference and either of
 the following statements is true.

  VAL is a blessed reference and is blessed into package TYPE or
  inherits from package TYPE 

  VAL is a reference to a TYPE of perl variable (er 'HASH')

I take the "if" to mean "if and only if", so
UNIVERSAL::isa(undef, anything) should return false.

Also, I suggest s/er/e.g./, and s/perl/Perl/ in the text there.

-- 
Sean M. Burke  sburke@netadventure.net  http://www.netadventure.net/~sburke/

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