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 ( [id://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

Replies are listed 'Best First'.
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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://729471]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-04-19 06:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found