Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.7.0
-
None
-
None
Description
I'd like to use a default value in a closure argument, but at the moment,
it's not working, and I was wondering if the thing I'm trying is not
supported...
This is my code:
Sheet.metaClass.dump =
{ Integer maxRows = Integer.MAX_VALUE -> }Code from Tim Yates:
This works:
def max = Integer.MAX_VALUE
String.metaClass.dump = { Integer maxRows = max ->
delegate.substring( 0, delegate.length() < maxRows ? delegate.length() : maxRows )
}
assert 'hello'.dump( 2 ) == 'he'
assert 'hello'.dump() == 'hello'
but as you say, putting the Integer.MAX_VALUE in the closure definition throws the MissingPropertyException.