SPVM::Comparator - Interface Type for Object Comparation Callback
use Comparator; use Point; my $comparator = (Comparator)method : int ($object1 : object, $object2 : object); { my $point1 = (Point)$object1; my $point2 = (Point)$object2; if ($point1->x > $point2->x) { return 1; } elsif ($point1->x < $point2->x) { return -1; } else { return 0; } }; my $point1 = Point->new(1, 2); my $point2 = Point->new(5, 6); my $result = $comparator->($point1, $point2);
Comparator is the interface type for the object comparation callback.
Comparator
required method : int ($object1 : object, $object2 : object);
This method must receive two objects and return the following value.
If the first argument is greater than the second argument, returns 1. If the first argument is lower than the second argument, returns -1. If the first argument is equal to the second argument, returns 0.
1
-1
0
To install SPVM, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SPVM
CPAN shell
perl -MCPAN -e shell install SPVM
For more information on module installation, please visit the detailed CPAN module installation guide.