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::String - A Callback Type for string Comparation

SYNOPSYS

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

DESCRIPTION

Comparator::String is a callback type to compare two strings.

CALLBACK METHOD

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

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