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

Re: Basic Objects with Overloaded Operators

by Adam (Vicar)
on Feb 22, 2001 at 07:40 UTC ( #60123=note: print w/replies, xml ) Need Help??

in reply to Basic Objects with Overloaded Operators

This is a well written article on the wonders of overloading and OO. But I have one complaint:
unless( ref($b) =~ /\S/ ){}
Is not a good way to find out if a variable is a reference to a Complex or not. The better way is UNIVERSAL::isa(). Every OO class inherits from UNIVERSAL, and so you can always call $object->isa(), like this:
unless( $b->isa( 'Complex' ) ){}
Other then that nit-pick, this is a good tutorial.

Replies are listed 'Best First'.
Re: Re: Basic Objects with Overloaded Operators
by perlmonkey (Hermit) on Feb 28, 2001 at 00:59 UTC
    Thanks for the comment! I have included the isa call into
    the root node. I wasn't familiar with isa when I wrote the
    article (many moons ago).
      unless(isa( $b, 'Complex' ) ) is more proper to cover the case when $b is not an object.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://60123]
[Corion]: Oooh. I had hoped that X::Tiny would be an X11 client or X11 server, but it is an exception framework :-)
[MidLifeXis]: How many languages would that 'Ex' alias handle. ETOOCUTE

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2017-02-27 11:48 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (383 votes). Check out past polls.