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::Cloner - A Callback Type to Clone a Object

SYNOPSYS

  use Cloner;
  
  my $cloner : Cloner = method : object ($object : object) {
    my $point = (Point)$object;
    
    my $new_point = Point->new($point->x, $point->y);
    
    return $new_point;
  };
  
  my $point = Point->new(1, 2);
  my $point_clone = $cloner->($point);

DESCRIPTION

Cloner is a callback type to clone a object.

CALLBACK METHOD

  method : object ($object : object);

The implementation must receive a object and return the cloned object.