Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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 <>
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://729471]
[oiskuu]: You want to draw the path? $iter = combinations( $TOP_HEIGHT .. $NODE_HEIGHT, $pos); then get the path from the iter, level change at depth x, for(..) $pos += $level_change; something like that
[oiskuu]: yergh, <code> tags... [$top_height .. $node_height]
[Eily]: Discipulus by demonstrate I suppose you mean simulate with perl?
[Eily]: the demonstration itself is fairly easy. The number of paths on a node is the sum of the numbers of paths to the two nodes above (or one node above on the edges of the triangle)
[Eily]: since the value of a node is also the sum from the two nodes above, you just have to demonstrate that the equality is true at the top of the triangle
[Discipulus]: yes Eily, thanks oiskuu but i dont get it.. ;=( maybe I'll ask a SOPW
[LanX]: all combinations with same amount of left and right?
[Eily]: if you want to store in a structure with the coordinates as key, arrays might do, since the keys are going to be 0..n
[LanX]: (Pascale path)
[Eily]: paths like that

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2018-03-19 11:16 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (239 votes). Check out past polls.