Example for switch case in Groovy
myValue = 40
switch (myValue) {
case 'Zvika':
println "you choose Zvika"
break
case 0..44:
println "This is a number between 0..44"
break
case 55:
println "The number is 55"
break
case ~/Zw?+a/:
println "your name starts with Z and ends in a!"
break
case Date:
println 'got a Date instance'
break
case ['God', 'Satan', 'Lotsipar', 'sun']:
println "Got one of the names above"
break
default:
println "Non of the case options "
}
אין תגובות:
הוסף רשומת תגובה