in reply to resurrecting objects?
Well, only you can know what it means for two of your objects to be "equal", so the best way would be for you to implement a compare method within the object that would compare the attributes of the object with a different object. You could then do something like this:
if ($obj1->compare($obj2)) { # ... }
Another nice touch would be to use overload to redefine the == or eq operators like this:
use overload '==' => \&compare;
You can then write code like this:
if ($obj1 == $obj2) { # ... }
But it's still your compare method that is actually being called.
--
"Perl makes the fun jobs fun
and the boring jobs bearable" - me
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: resurrecting objects?
by perchance (Monk) on May 03, 2001 at 15:01 UTC | |
by davorg (Chancellor) on May 03, 2001 at 15:08 UTC | |
by tilly (Archbishop) on May 04, 2001 at 00:01 UTC | |
by tye (Sage) on May 04, 2001 at 01:58 UTC | |
by MeowChow (Vicar) on May 04, 2001 at 00:28 UTC |