20 lines
362 B
Groovy
20 lines
362 B
Groovy
|
def myList = [1,2,3,4,5,6,7,8,9,10]
|
||
|
def emptyList = []
|
||
|
|
||
|
def check(List<Integer> list) {
|
||
|
def counter = 0
|
||
|
|
||
|
if (list.size() == 0) {
|
||
|
return "Die übergebene Liste ist leer!"
|
||
|
}
|
||
|
for(i in 0..<list.size()) {
|
||
|
if(list[i] % 2 == 0) {
|
||
|
counter++
|
||
|
}
|
||
|
}
|
||
|
return counter
|
||
|
}
|
||
|
|
||
|
println check(myList)
|
||
|
println check(emptyList)
|