http://qs321.pair.com?node_id=729471


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