Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Do not use UNIVERSAL::isa this way; but why?

by brian_d_foy (Abbot)
on Dec 10, 2008 at 18:03 UTC ( #729471=note: print w/ replies, xml ) Need Help??


in reply to Re: Do not use UNIVERSAL::isa this way; but why?
in thread Do not use UNIVERSAL::isa this way; but why?

The problem with $fd->isa(...) is that it crashes if $fd is undef, whereas a simple "no" would be better. If they made that work at the same time as inheritance, that'd be awesome :-) Most likely, that would just be:

The idiom is to wrap it in an eval:

my $answer = eval { $fd->isa(...) };

If it's not an object or isn't the right type, you get false. It doesn't matter to you why it is false because in both cases it's not the object type you are looking for.

--
brian d foy <brian@stonehenge.com>
Subscribe to The Perl Review


Comment on Re^2: Do not use UNIVERSAL::isa this way; but why?
Download Code
Re^3: Do not use UNIVERSAL::isa this way; but why?
by ysth (Canon) on Dec 14, 2008 at 20:46 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://729471]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2014-12-20 09:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (95 votes), past polls