Functions can have an optional argument as value by assigning it at the definition:
func multiply(a: int, b: int = 2) -> int:
return a * b
var result = multiply(2, 3) # result is 6
var result = multiply(4) # result is 8
Comments
Functions can have an optional argument as value by assigning it at the definition:
func multiply(a: int, b: int = 2) -> int:
return a * b
var result = multiply(2, 3) # result is 6
var result = multiply(4) # result is 8