Represents a short ternary expression x ?: y, which is equal to
def truePart = x def booleanPart = truePart as boolean booleanPart? truePart : yEven if x is no atomic expression, x will be evaluated only once. Example:
class Foo { def index=0 def getX(){ index++; return index } } def foo = new Foo() def result = foo.x ?: "false case" assert foo.index == 1 assert result == 1
Constructor and description |
---|
ElvisOperatorExpression
(Expression base, Expression falseExpression) |
Type Params | Return Type | Name and description |
---|---|---|
|
Expression |
transformExpression(ExpressionTransformer transformer) |
|
void |
visit(GroovyCodeVisitor visitor) |
Copyright © 2003-2019 The Apache Software Foundation. All rights reserved.