-
Notifications
You must be signed in to change notification settings - Fork 14
Perl Porting to SPVM
Yuki Kimoto edited this page Feb 23, 2024
·
1 revision
Perl:
# Getter/Setter method for the foo field of string
sub foo {
my $self = shift;
if (@_) {
$sefl->{foo} = $_[0];
return;
}
return $self->{foo}
}
SPVM:
# Field
has foo : rw string;
or
method foo : string () {
return $self->{foo};
}
method set_foo : void ($foo : string) {
$sefl->{foo} = $foo;
}
The void return type is recommned for setter methods in SPVM.