This is copied from my email:
--------------
I can have a "normal" method in a class, that has default values for some of its parameters:
class A {
def someMethod(a, b, c= null) { ... }
}
This allows me to do:
def a= new A()
a.someMethod(1, 2, 3)
a.someMethod(1, 2) // third one 'c' defaults to null
If I had not defined the third param of 'someMethod' as accepting a default value, the second call would have failed with a "No signature...." exception.
So far, so good.
Now, if I want to do something similar with a method added through the MetaClass:
A.metaClass.someMeta = {a, b, c= null ->
println "this is someMeta $a $b $c"
}
a.someMeta(1, 2, 3) // good
a.someMeta(1, 2) // fails!!!
1) Observation number one: default-value parameters work for normal closures:
def someClo = {a, b, c= 789 ->
println "clo clo $a $b $c"
}
someClo(44, 55) // this one works, printing 789 for 'c'
2) Observation number two: when adding through the MetaClass you lose that feature...