15 lines
433 B
Groovy
15 lines
433 B
Groovy
|
class Person {
|
||
|
def name
|
||
|
def alter
|
||
|
}
|
||
|
|
||
|
def personen = [new Person(name: "Max", alter: 12), new Person(name: "Karl", alter: 40), new Person(name: "Laura", alter: 23)]
|
||
|
|
||
|
def volljaehrig = { person -> person.alter > 17}
|
||
|
def erwachsenePersonen = personen.findAll(volljaehrig)
|
||
|
|
||
|
def nameInGrossbuchstaben = { person -> person.name.toUpperCase() }
|
||
|
def ergebnis = erwachsenePersonen.collect(nameInGrossbuchstaben)
|
||
|
|
||
|
println ergebnis
|