in reply to Re: Returning a Junction
in thread Returning a Junction
Only problem is that, while my example above used the any() style junction, there is also the all() type (i.e., all elements in the junction must match).
Probably the best way around this is to split into two packages: junction_any and junction_all. The implementation for compare under junction_all would be something like this:
sub compare { my $self = shift; my $string = shift; foreach my $key (keys %{ $self }) { return 0 if $string ne $key; } return 1; }
For completeness, you'll want to provide equivilent overloading for the other comparison operators, too.
----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
Note: All code is untested, unless otherwise stated
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Returning a Junction
by fletcher_the_dog (Friar) on Sep 04, 2003 at 19:40 UTC | |
by dragonchild (Archbishop) on Sep 04, 2003 at 19:53 UTC |