I've suggested last week the creation of the "?:=" constructor in Groovy:
It was rejected and a new JIRA was requested to be created with a new operator.
Then, I've talked to the Grails users in their mailing list to get some feedback, which can be read here:
Then, Phil DeJarnett has suggested using "?=" instead of "?:=". Not only I preferred this suggestion, but I was changed my mind about its meaning too.
It would be used as a caching/memoization operator mostly. It would be similar to Ruby's "||=", except for this specific situation:
That is why "a ||= value" is expanded to "a = a || value"
But for caching/memoization, I'd prefer "a ?= value" to be expanded to "a = a == null ? value : a". This way we would have:
Proposed Groovy syntax:
I'll actually fill a new ticket on Ruby Redmine too for proposing the same syntax and semanthics