...
| Code Block |
|---|
def x = false
def y = false
if ( !x ) {
x = true
}
assert x == true
if ( x ) {
x = false
} else {
y = true
}
assert x == y
|
if - else statement
Groovy also supports the normal Java "nested" if then else if syntax:
| Code Block |
|---|
if ( ... ) {
...
} else if (...) {
...
} else {
...
}
|
ternary operator
Groovy also supports the ternary operator:
...