The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

Name

SPVM::Comparator::Int - Interface Type for int Comparation Callback

Usage

  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 the interface type for the int comparation callback.

Interface Methods

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

This method must receive two values that types are int 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.