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::Int - A Callback Type for int Comparation

SYNOPSYS

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

DESCRIPTION

Comparator::Int is a callback type to compare two int values.

CALLBACK METHOD

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

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.