15 lines
395 B
Groovy
15 lines
395 B
Groovy
class Person {
|
|
def name
|
|
def alter
|
|
|
|
def printIfAdult() {
|
|
if (this.alter > 17) {
|
|
println this.name + " ist volljährig."
|
|
}
|
|
}
|
|
}
|
|
|
|
def personen = [new Person(name: "Max", alter: 12), new Person(name: "Karl", alter: 40), new Person(name: "Laura", alter: 23), new Person(name: "Ali", alter: 15)]
|
|
|
|
// Hier den Spread-Operator benutzen
|
|
personen*.printIfAdult() |