groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Sun <>
Subject Re: [VOTE] new operator ?=
Date Thu, 24 Nov 2016 00:30:22 GMT
I like the nickname "Elvis assignment" for ?=


在 2016年11月24日 04:18,"Guillaume Laforge [via Groovy]" <>写道:<br
Sounds about right.

On Wed, Nov 23, 2016 at 9:07 PM, Shil Sinha <[hidden email]</user/SendEmail.jtp?type=node&node=5736959&i=0>>
Elvis assignment?

On Wed, Nov 23, 2016 at 1:47 PM Andres Almiray <[hidden email]</user/SendEmail.jtp?type=node&node=5736959&i=1>>
Long live pompaduor walrus ...

What would be an appropriate nickname for ?=, I wonder.

Java Champion; Groovy Enthusiast
What goes up, must come down. Ask any system administrator.
There are 10 types of people in the world: Those who understand binary, and those who don't.
To understand recursion, we must first understand recursion.

On Wed, Nov 23, 2016 at 7:35 PM, Paul King <[hidden email]</user/SendEmail.jtp?type=node&node=5736959&i=2>>
For all our other operators of the form:

a X= b

it is shorthand for:

a = a X b

So, to follow that convention the operator is:

a ?:= b

which as per previous discussions is a bit cumbersome, so I am +1 for
the shortened form so long as we document appropriately.


On Thu, Nov 24, 2016 at 3:54 AM, Gerald Wiltse <[hidden email]</user/SendEmail.jtp?type=node&node=5736959&i=3>>
> +1
> Gerald R. Wiltse
> [hidden email]</user/SendEmail.jtp?type=node&node=5736959&i=4>
> On Wed, Nov 23, 2016 at 12:28 PM, Winnebeck, Jason
> <[hidden email]</user/SendEmail.jtp?type=node&node=5736959&i=5>>
>> 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:
>> = ?: "unknown"
>> When you have a non-trivial assignment expression, I see the benefit:
>> ?= "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:[hidden email]</user/SendEmail.jtp?type=node&node=5736959&i=6>]
>> Sent: Wednesday, November 23, 2016 10:59 AM
>> To: [hidden email]</user/SendEmail.jtp?type=node&node=5736959&i=7>
>> 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:
>> Sent from the Groovy Users mailing list archive at
>> 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.

Guillaume Laforge
Apache Groovy committer & PMC Vice-President
Developer Advocate @ Google Cloud Platform

Social: @glaforge<> / Google+<>

If you reply to this email, your message will be added to the discussion below:
To unsubscribe from [VOTE] new operator ?=, click here<>.

View this message in context:
Sent from the Groovy Users mailing list archive at
View raw message