The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

SPVM::Comparator::Long - A Callback Type for long Comparation

SYNOPSYS

  use Comparator::Long;
  
  my $comparator : Comparator::Long = method : int ($a : long, $b : long); {
    return $a <=> $b;
  };
  
  my $result = $comparator->(3, 5);

DESCRIPTION

Comparator::Long is an interface type for the callback to compare two long values.

INTERFACE METHOD

  required method : int ($a : long, $b : long);

The implementation must receive two numbers and return 1 if $a is more than $b, -1 if $x is less than $b, 0 if $a equals $b in the implementation.