Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.0-JSR-6
-
None
-
None
-
JRE 1.5.0_07 on Windows XP prof edn
Description
When calling a method defined in a category written in Groovy, default parameters aren't recognised. An example...
class ExtendedJoin{
static String join(Collection self, String separator, int perLine, String lineSeparator= '\r\n'){
def buffer= new StringBuffer(), first= true, i=0
if(separator == null) separator= ''
self.each{
if(first) first= false else buffer<< separator
if( i >perLine)
buffer<< it
i += it.size()
}
buffer.toString()
}
}
use(ExtendedJoin){
//this one works OK...
println( ['the', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog'].join(' ',20,'\r\n') )
//but this one doesn't pick up the default param value...
println( ['the', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog'].join(' ',20) )
//Caught: groovy.lang.MissingMethodException: No signature of method java.util.ArrayList.join()
//is applicable for argument types: (java.lang.String, java.lang.Integer) values:
}