Ex 4: Groovy (diff 2) - Groovin' with Groovy | [ Prev | Home | Next ] |
import java.util.*
class Erase {
public static main(args) {
names = [ "Ted", "Fred", "Jed", "Ned" ]
System.out.println()
e = new Erase()
short_names = e.filterLongerThan(names, 3)
System.out.println (short_names.size())
for (s in short_names) {
System.out.println(s)
}
}
public filterLongerThan (strings, length) {
result = strings.findAll { ???? }
return result
}
}
Copyright 2004 by Jim Weirich (Some Rights Reserved) |