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
In reply to Re: Re: Returning a Junction
by hardburn
in thread Returning a Junction
by hardburn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |