Default value expression
In first proposal of subroutine signatures, default value is the following.
sub func($foo //= 0, $bar ||= 0) {
}
I think this can use only "=" as same as many ohter languages. and "||" is in body if needed.
sub func($foo = 0, $bar) {
$bar ||= 0;
}
This expression is general in other languages.
PHP
function makecoffee($type = "cappuccino")
{
return "Making a cup of $type.\n";
}
Python
def func_default(arg1, arg2='default_x', arg3='default_y'):
print(arg1)
print(arg2)
print(arg3)
Ruby
def printHello(msg="No msg", name="No name") print(msg + "," + name + "¥n") end