4 ms·
Groovy allows you to specify types of method parameters, return values, fields and local variables. This was needed for Java integration, but has the benefit t
by martincmartin 18y ago
Groovy allows you to specify types of method parameters, return values, fields and local variables. This was needed for Java integration, but has the benefit that you get runtime checks for types. So in Ruby you might do:
def foo(mystring):
assert mystring type_of? String
mystring.length
end
In Groovy you could just do:
def foo(String mystring) {
mystring.length
}