Are default values supported for attributive parameters in an argument list?
I wish to convert these 2 subroutines to perl6:
sub foo {
my $self = shift;
$self->{foo} = defined $_[0] ? shift : undef;
}
sub bar {
my $self = shift;
$self->{bar} = defined $_[0] ? shift : $DEFAULT;
}
Is this correct?
method foo (?$.foo = undef) {};
method bar (?$.bar = $DEFAULT) {};
Thanks,
Carl
Thread Next