groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <eric.mil...@thomsonreuters.com>
Subject GROOVY-5306 (?= operator)
Date Mon, 05 Mar 2018 15:23:46 GMT
GROOVY-5306 (https://issues.apache.org/jira/browse/GROOVY-5306) states:

Add "a ?= 2" support: should be expanded to "a = a == null ? 2 : a"

Shouldn't the expansion be "a = (a != null ? a : 2)"?  Like other ternary situations, the
alternative would not be evaluated unless needed.  Also, is it a null check and not Groovy
truth in the condition?

If "a" is not null in this example, does the bytecode actually execute an assignment?  That
seems unnecessary as well.


Mime
View raw message