import java.util.*
class Erase {
public static main(args) {
names = [ "Ted", "Fred", "Jed", "Ned" ]
System.out.println(names)
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 { s | s.length() < length+1 }
return result
}
}
- Finally, it’s a shame that a commonly used routine is spelled
"System.out.println". Why don’t we shorten that to
"println" and drop the parenthesis while we are at it.