Actions
Bug #20041
openArray destructuring and default values in parameters
Description
It's possible to set the default value of a parameter to a previous parameter. For example:
def foo(a, b = a)
b
end
foo([1, 2]) # => [1, 2]
However, if the parameters are destructured, the destructring happens after default parameter assignment. For example:
def foo((x, y), b = x)
[x, y, b]
end
foo([1, 2]) # => [1, 2, nil]
Is this expected behavior? I would have expected the parameters to be "evaluated" from left to right, and the array destructuring to happen before the default parameter assignment.
Thanks!
Actions
Like0
Like1Like0Like0Like0