At first I was going to vote 0, because I feel like a = a ?: b is clear (and I compare it to a = a || b from JS). However, looking at the dev list, I definitely see a nice case for it:
person.name.last = person.name.last ?: "unknown" When you have a non-trivial assignment expression, I see the benefit: person.name.last ?= "unknown" However, I feel like it is not intuitive or clear. But, I don't think the operator hurts, and it's certainly not any less intuitive than <=> for example or even ?: when seen for the very first time. It's an easy look up in Groovy docs, and if you don't know it and don't use it, it's not a huge loss. So it doesn't hurt to add it, and while not instantly readable, it's a trivial docs lookup when someone is reading the code. So, I vote +1. But, honestly, I don't see myself using it very often as I'd normally use Elvis at time of initial assignment. I wouldn't put it very high on a prioritized backlog of things to improve for Groovy. Jason -----Original Message----- From: Daniel Sun [mailto:[email protected]] Sent: Wednesday, November 23, 2016 10:59 AM To: [email protected] Subject: [VOTE] new operator ?= Hi all, If the new operator ?= (e.g. a ?= 'foo' is equivalent of a = a ?: 'foo') were to be added to Groovy programming language, do you like it? (Yes: +1; No: -1; Not bad: 0) Cheers, Daniel.Sun -- View this message in context: http://groovy.329449.n5.nabble.com/VOTE-new-operator-tp5736931.html Sent from the Groovy Users mailing list archive at Nabble.com. This email message and any attachments are for the sole use of the intended recipient(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message and any attachments.
