groovy-lecture/live/solutions/operatoren.groovy

9 lines
297 B
Groovy

def words = ["Groovy", "ist", "cool"]
def numbers = [1, 2, 3, 4, 5]
def lengths = words*.length()
def squares = numbers*.multiply(numbers)
println("Längen: ${lengths}") // Erwartete Ausgabe: Längen: [6, 3, 4]
println("Quadrate: ${squares}") // Erwartete Ausgabe: Quadrate: [1, 4, 9, 16, 25]