Details
-
Type:
New Feature
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.6.2
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Testcase included:yes
-
Number of attachments :
Description
Currently, there is no way of calling a method with sparse optional parameters that are not sequential with respect to the order in which the parameters are declared.
Python offers this flexibility, and it makes sense that Groovy allow it, too. When implemented, the following would be expected to pass:
public def foo(int a, int b = 42, int c = 314) { return [a, b, c] } // the following two cases pass, atm. assert foo(1) == [1, 42, 314] assert foo(1, 2) == [1, 2, 314] // the following three cases fail, atm. assert foo(1, b: 2) == [1, 2, 314] assert foo(1, c: 3) == [1, 42, 3] assert foo(1, b: 2, c: 3) == [1, 2, 3]
It seems this would require true named parameters in the first place, a feature which Groovy doesn't have at the moment.