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

Name

SPVM::Cloneable - Interface Type to Clone Object

Usage

  class Point {
    interface Cloneable;
    
    method clone : Point () {
      my $new_point = Point->new($self->x, $self->y);
      
      return $new_point;
    }
  }

Description

Cloneable is a callback interface to clone a object.

Interface Methods

Interface methods.

clone

  required method clone : object ();

The implementation must return the cloned object.