SPVM::E...yChecker(3)
π Name π
Hiii bestie π welcome to the SPVM::E...yChecker(3) page β a User Contributed Perl Documentation moment β for SPVM::EqualityChecker.
SPVM::EqualityChecker β Interface Type for Object Equality Checking Callback π
π οΈ Usage π οΈ
Okay so hereβs the whole little demo, bestie β copy-paste carefully and watch the indentation, iykyk π
use EqualityChecker;
use Point;
my $equality_checker = (EqualityChecker)method : int ($object1 : object, $object2 : object) {
my $point1 = (Point)$object1;
my $point2 = (Point)$object2;
if ($point1->x == $point2->x && $point1->y == $point2->y) {
return 1;
}
else {
return 0;
}
};
my $point1 = Point->new(1, 2);
my $point2 = Point->new(5, 6);
my $is_equal = $equality_checker->($point1, $point2);
π Description π
So EqualityChecker is the interface type for the object equality checking callback β¨ Thatβs the whole vibe: itβs the interface type for the callback that checks object equality, periodt π
π§ Interface Methods π§
required method : int ($object1 : object, $object2 : object)
The implementation must receive two objects and if they are equal, return 1. Otherwise, return 0. No cap, thatβs the rule π«Ά
π Class Methods π
default_equality_checker
static method default_equality_checker : EqualityChecker ();
It returns a default default equality checker β yes, double default is literally what the original says, bestie π
The implementation of the default equality checker is:
method : int ($object1 : EqualityCheckable, $object2 : EqualityCheckable) {
my $eq = 0;
if ($object1 && $object2) {
$eq = $object1->eq($object1, $object2);
}
elsif ($object1) {
$eq = 0;
}
elsif ($object2) {
$eq = 0;
}
else {
$eq = 1;
}
return $eq;
};
Hereβs the behavior check, bestie πΈ
- If
$object1and$object2are defined, the check of equality isperfermedbyEqualityCheckable#eqmethod in the class of$object1, and returns its return value. (Yes,perfermedis exactly the original spelling β we keep the lore π) - If only
$object1is defined, returns0. - If only
$object2is defined, returns0. - If both
$object1and$object2are not defined, returns1.
π Copyright & License π
Copyright (c) 2023 Yuki Kimoto
MIT License
Thatβs the legal tea, bestie π
Catch you later, bestie β this page is from perl v5.42.2 and dated 2026-02-03 πβ¨
π¦ where this page comes from
- alpine 3.24: spvm-doc 0.990125-r0 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms