You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@groovy.apache.org by Daniel Sun <re...@hotmail.com> on 2016/11/22 14:14:40 UTC
[PROPOSAL]new operator ?=
Hi all,
Marcin Erdmann proposed the new operator ?=, e.g. a ?= "foo" is
equivalent of a = a ?: "foo".
I like his idea, what do you think about it?
Cheers,
Daniel.Sun
--
View this message in context: http://groovy.329449.n5.nabble.com/PROPOSAL-new-operator-tp5736886.html
Sent from the Groovy Dev mailing list archive at Nabble.com.
Re: [PROPOSAL]new operator ?=
Posted by Guillaume Laforge <gl...@gmail.com>.
It's on purpose that it should be close to the Elvis operator :-)
On Thu, Nov 24, 2016 at 9:33 PM, Konstantin Boudnik <co...@apache.org> wrote:
> It's painfully close to the elvis operator, isn't it?
>
> On Tue, Nov 22, 2016 at 07:14AM, Daniel Sun wrote:
> > Hi all,
> >
> > Marcin Erdmann proposed the new operator ?=, e.g. a ?= "foo" is
> > equivalent of a = a ?: "foo".
> >
> > I like his idea, what do you think about it?
> >
> > Cheers,
> > Daniel.Sun
> >
> >
> >
> > --
> > View this message in context: http://groovy.329449.n5.
> nabble.com/PROPOSAL-new-operator-tp5736886.html
> > Sent from the Groovy Dev mailing list archive at Nabble.com.
>
--
Guillaume Laforge
Apache Groovy committer & PMC Vice-President
Developer Advocate @ Google Cloud Platform
Blog: http://glaforge.appspot.com/
Social: @glaforge <http://twitter.com/glaforge> / Google+
<https://plus.google.com/u/0/114130972232398734985/posts>
Re: [PROPOSAL]new operator ?=
Posted by Konstantin Boudnik <co...@apache.org>.
It's painfully close to the elvis operator, isn't it?
On Tue, Nov 22, 2016 at 07:14AM, Daniel Sun wrote:
> Hi all,
>
> Marcin Erdmann proposed the new operator ?=, e.g. a ?= "foo" is
> equivalent of a = a ?: "foo".
>
> I like his idea, what do you think about it?
>
> Cheers,
> Daniel.Sun
>
>
>
> --
> View this message in context: http://groovy.329449.n5.nabble.com/PROPOSAL-new-operator-tp5736886.html
> Sent from the Groovy Dev mailing list archive at Nabble.com.
Re: [PROPOSAL]new operator ?=
Posted by Roman Shaposhnik <ro...@shaposhnik.org>.
On Tue, Nov 22, 2016 at 5:14 PM, Daniel Sun <re...@hotmail.com> wrote:
> Hi all,
>
> Marcin Erdmann proposed the new operator ?=, e.g. a ?= "foo" is
> equivalent of a = a ?: "foo".
>
> I like his idea, what do you think about it?
Like it! I could definitely see myself using it.
Thanks,
Roman.
Re: [PROPOSAL]new operator ?=
Posted by Andres Almiray <aa...@gmail.com>.
FWIW
[image: Inline image 1] *aalmiray*
If a shorthand notation for Groovy’s Elvis (?:) + assignment were to be
added, which one would you pick?
22/11/16 15:44 <https://twitter.com/aalmiray/status/801073756693151744>
49 votes so far.
48% in favor of ?=
10% in favor of ||=
20% in favor of ?:=
22% had no clue.
In hindsight the 4th option should have been "no thanks".
On Wed, Nov 23, 2016 at 9:34 AM, Marcin Erdmann <ma...@proxerd.pl>
wrote:
> Jochen Theodorou wrote
> > So for me a new operator makes more sense. But frankly...
> >
> >> def foo(x) {
> >> return x ?: "empty"
> >> }
> >
> > or even
> >
> >> def foo(x) {
> >> x = x ?: "empty"
> >> return x
> >> }
> >
> > vs.
> >
> >> def foo(x) {
> >> x ?= "empty"
> >> return x
> >> }
> >
> > Is that really worth it? Does it really improve readability that much?
> > Or maybe someone has a better example?
>
> I will chip in as the person who proposed that new operator on Twitter to
> Daniel (thanks Daniel and Guillaume for raising it for discussion here).
> This idea came up when I needed to add a default key in a map pre-populated
> with another map:
>
> def options = [:]
> options.putAll(userOptions)
> options.fit = options.fit ?: "max"
>
> I think that from the above you can see that this operator makes more sense
> when you are defaulting a value that is nested and not just a local
> variable. To make it even more drastic:
>
> foo.options.fit = foo.options.fit ?: "max"
>
> vs.
>
> foo.options.fit ?= "max"
>
> I now see that I could actually simplify the first example in my email to:
>
> def options = [fit: "max"]
> options.putAll(userOptions)
>
> but this is not the first time that I wish this operator existed.
>
> Anyway, I see that it looks like Daniel has decided that it's not worth the
> effort but thanks to everybody for taking my proposal into consideration.
>
> Cheers,
> Marcin
>
>
>
> --
> View this message in context: http://groovy.329449.n5.
> nabble.com/PROPOSAL-new-operator-tp5736886p5736916.html
> Sent from the Groovy Dev mailing list archive at Nabble.com.
>
Re: [PROPOSAL]new operator ?=
Posted by Cédric Champeau <ce...@gmail.com>.
Same here, +1 to ?=
This wasn't explicitly stated, but I want to make it clear, regarding the
semantics of this operator. I guess it implies "Groovy truth", not "null
check" (and we could apply the same kind of optimizations as we have for ?:
in static compilation).
2016-11-23 16:20 GMT+01:00 Graeme Rocher <gr...@gmail.com>:
> +1 for ?=
>
> Cheers
>
> On Wed, Nov 23, 2016 at 12:49 PM, Daniel Sun <re...@hotmail.com>
> wrote:
> > Hi Jochen,
> >
> >> Maybe we should start a vote of ?= or not... maybe on the user list...
> >> then we see what people think. Daniel might have been a bit too fast
> here
> > I'd like to start the vote of ?= ;)
> >
> > Just ask whether like it or not? Or like Andres's vote, ask which
> > operator do you like:
> > 1) ?=
> > 2) ?:=
> > 3) none
> >
> > Cheers,
> > Daniel.Sun
> >
> >
> >
> > --
> > View this message in context: http://groovy.329449.n5.
> nabble.com/PROPOSAL-new-operator-tp5736886p5736922.html
> > Sent from the Groovy Dev mailing list archive at Nabble.com.
>
>
>
> --
> Graeme Rocher
>
Re: [PROPOSAL]new operator ?=
Posted by Jim Jagielski <ji...@jaguNET.com>.
+1
> On Nov 23, 2016, at 10:20 AM, Graeme Rocher <gr...@gmail.com> wrote:
>
> +1 for ?=
>
Re: [PROPOSAL]new operator ?=
Posted by Graeme Rocher <gr...@gmail.com>.
+1 for ?=
Cheers
On Wed, Nov 23, 2016 at 12:49 PM, Daniel Sun <re...@hotmail.com> wrote:
> Hi Jochen,
>
>> Maybe we should start a vote of ?= or not... maybe on the user list...
>> then we see what people think. Daniel might have been a bit too fast here
> I'd like to start the vote of ?= ;)
>
> Just ask whether like it or not? Or like Andres's vote, ask which
> operator do you like:
> 1) ?=
> 2) ?:=
> 3) none
>
> Cheers,
> Daniel.Sun
>
>
>
> --
> View this message in context: http://groovy.329449.n5.nabble.com/PROPOSAL-new-operator-tp5736886p5736922.html
> Sent from the Groovy Dev mailing list archive at Nabble.com.
--
Graeme Rocher
Re: [PROPOSAL]new operator ?=
Posted by Daniel Sun <re...@hotmail.com>.
Hi Jochen,
> Maybe we should start a vote of ?= or not... maybe on the user list...
> then we see what people think. Daniel might have been a bit too fast here
I'd like to start the vote of ?= ;)
Just ask whether like it or not? Or like Andres's vote, ask which
operator do you like:
1) ?=
2) ?:=
3) none
Cheers,
Daniel.Sun
--
View this message in context: http://groovy.329449.n5.nabble.com/PROPOSAL-new-operator-tp5736886p5736922.html
Sent from the Groovy Dev mailing list archive at Nabble.com.
Re: [PROPOSAL]new operator ?=
Posted by Jochen Theodorou <bl...@gmx.org>.
On 23.11.2016 09:34, Marcin Erdmann wrote:
[...]
> I will chip in as the person who proposed that new operator on Twitter to
> Daniel (thanks Daniel and Guillaume for raising it for discussion here).
> This idea came up when I needed to add a default key in a map pre-populated
> with another map:
>
> def options = [:]
> options.putAll(userOptions)
> options.fit = options.fit ?: "max"
well, you could have done this:
def options = [ fit : "max" ]
options.putAll(userOptions)
then there is no show time for elvis
> I think that from the above you can see that this operator makes more sense
> when you are defaulting a value that is nested and not just a local
> variable. To make it even more drastic:
>
> foo.options.fit = foo.options.fit ?: "max"
>
> vs.
>
> foo.options.fit ?= "max"
or Cedric's variant:
foo.options.with {
fit ?= "max" //fit = fit ?: "max"
}
Maybe my problem stems more from me not really being happy with ?= as
symbol group. For a ?: b being the short form of a? a : b is pretty
straightforward. Having a reduction of the reduction... well that's
where you can easily loose context. It is then not so easy anymore that
a ?= b is the short form of a = a ? a : b... especially since this is a
pretty special case with rare usages. And going by the usually pattern
this really would have to be a ?:= b, which is just too much ASCII-art
for some here.
I mean something like a += b is kind of special too, but it is also many
times more common than ?=, because calculations are a much more common
case than after-the-fact-initialization
[...]
> Anyway, I see that it looks like Daniel has decided that it's not worth the
> effort but thanks to everybody for taking my proposal into consideration.
Maybe we should start a vote of ?= or not... maybe on the user list...
then we see what people think. Daniel might have been a bit too fast here
bye Jochen
Re: [PROPOSAL]new operator ?=
Posted by Marcin Erdmann <ma...@proxerd.pl>.
Jochen Theodorou wrote
> So for me a new operator makes more sense. But frankly...
>
>> def foo(x) {
>> return x ?: "empty"
>> }
>
> or even
>
>> def foo(x) {
>> x = x ?: "empty"
>> return x
>> }
>
> vs.
>
>> def foo(x) {
>> x ?= "empty"
>> return x
>> }
>
> Is that really worth it? Does it really improve readability that much?
> Or maybe someone has a better example?
I will chip in as the person who proposed that new operator on Twitter to
Daniel (thanks Daniel and Guillaume for raising it for discussion here).
This idea came up when I needed to add a default key in a map pre-populated
with another map:
def options = [:]
options.putAll(userOptions)
options.fit = options.fit ?: "max"
I think that from the above you can see that this operator makes more sense
when you are defaulting a value that is nested and not just a local
variable. To make it even more drastic:
foo.options.fit = foo.options.fit ?: "max"
vs.
foo.options.fit ?= "max"
I now see that I could actually simplify the first example in my email to:
def options = [fit: "max"]
options.putAll(userOptions)
but this is not the first time that I wish this operator existed.
Anyway, I see that it looks like Daniel has decided that it's not worth the
effort but thanks to everybody for taking my proposal into consideration.
Cheers,
Marcin
--
View this message in context: http://groovy.329449.n5.nabble.com/PROPOSAL-new-operator-tp5736886p5736916.html
Sent from the Groovy Dev mailing list archive at Nabble.com.
Re: [PROPOSAL]new operator ?=
Posted by Jochen Theodorou <bl...@gmx.org>.
On 22.11.2016 15:25, Guillaume Laforge wrote:
> It's a feature that's often be requested.
> I think Ruby's got an equivalent with ||=, and it's often the reference
> people give when exploring our Elvis operator coming from a ruby
> background in particular.
> I've had several opportunities where I could've used this operator.
> It might make for a nice addition.
while I agree that ||= is more like what ruby offers we have the
problem, that for Groovy a||b always will be evaluated as boolean.
In fact first we apply groovy truth to a and if that is not true, we do
the same for b and if that is not true we return false, otherwise true.
Which means a = a||b would not be equal to a ||= b if that is supposed
to be the same as proposed for ?=.
What would come near to that is |, which is mapped to a method call to
"or". And then again, it has already a meaning for numbers, that does
not fit.
So for me a new operator makes more sense. But frankly...
> def foo(x) {
> return x ?: "empty"
> }
or even
> def foo(x) {
> x = x ?: "empty"
> return x
> }
vs.
> def foo(x) {
> x ?= "empty"
> return x
> }
Is that really worth it? Does it really improve readability that much?
Or maybe someone has a better example?
it is different for !in and !instanceof, because of the spacing and
because you may have them in complex expressions. But ?= is a statement
and I would very much dislike this usage as expression.
For now I am -1 on this
bye Jochen
Re: [PROPOSAL]new operator ?=
Posted by Shil Sinha <sh...@gmail.com>.
>
> while I agree that ||= is more like what ruby offers we have the problem,
> that for Groovy a||b always will be evaluated as boolean.
> In fact first we apply groovy truth to a and if that is not true, we do
> the same for b and if that is not true we return false, otherwise true.
> Which means a = a||b would not be equal to a ||= b if that is supposed to
> be the same as proposed for ?=.
-1 for ||= for this reason.
On Tue, Nov 22, 2016 at 12:02 PM, Jochen Theodorou <bl...@gmx.org>
wrote:
> hmm... actually you might be right there... sorry
>
> On 22.11.2016 17:46, Sébastien Le Callonnec wrote:
>
>> Hi,
>>
>> On 2016-11-22 16:28:25, Jochen Theodorou wrote:
>>
>>> you can unsusbscribe from the incubator list, we are not in incubator
>>> anymore
>>>
>>
>> Fair enough. I was under the impression the dev list was an alias of
>> the incubator list created when the project graduated, but I was
>> obviously mistaken.
>>
>> Thanks,
>> Sébastien.
>>
>>
Re: [PROPOSAL]new operator ?=
Posted by Jochen Theodorou <bl...@gmx.org>.
hmm... actually you might be right there... sorry
On 22.11.2016 17:46, S�bastien Le Callonnec wrote:
> Hi,
>
> On 2016-11-22 16:28:25, Jochen Theodorou wrote:
>> you can unsusbscribe from the incubator list, we are not in incubator
>> anymore
>
> Fair enough. I was under the impression the dev list was an alias of
> the incubator list created when the project graduated, but I was
> obviously mistaken.
>
> Thanks,
> S�bastien.
>
Re: [PROPOSAL]new operator ?=
Posted by Sébastien Le Callonnec <sl...@yahoo.ie>.
Hi,
On 2016-11-22 16:28:25, Jochen Theodorou wrote:
> you can unsusbscribe from the incubator list, we are not in incubator
> anymore
Fair enough. I was under the impression the dev list was an alias of
the incubator list created when the project graduated, but I was
obviously mistaken.
Thanks,
S�bastien.
Re: [PROPOSAL]new operator ?=
Posted by Jochen Theodorou <bl...@gmx.org>.
you can unsusbscribe from the incubator list, we are not in incubator
anymore
On 22.11.2016 16:03, S�bastien Le Callonnec wrote:
> Hi,
>
> Completely OT, but would it be possible not to cross-post on dev and
> incubator lists: I believe these are the same lists. I keep getting
> duplicate emails, in any case. Thanks! ;)
>
> (Back on topic, `?=` is a good idea \u2013 call it the \u201cionic column\u201d
> operator)
>
> Regards,
> S�bastien.
>
> On 2016-11-22 14:39:45, Andres Almiray wrote:
>> I think ||= conveys the exact meaning of the operand whereas ?= is missing
>> the : to properly indicate that's a shorthand for Elvis.
>> ?:= would be a walrus sporting a pompaduor if you ask me ;-)
>>
>> -------------------------------------------
>> Java Champion; Groovy Enthusiast
>> http://jroller.com/aalmiray
>> http://www.linkedin.com/in/aalmiray
Re: [PROPOSAL]new operator ?=
Posted by Sébastien Le Callonnec <sl...@yahoo.ie>.
Hi,
Completely OT, but would it be possible not to cross-post on dev and
incubator lists: I believe these are the same lists. I keep getting
duplicate emails, in any case. Thanks! ;)
(Back on topic, `?=` is a good idea \u2013 call it the \u201cionic column\u201d
operator)
Regards,
S�bastien.
On 2016-11-22 14:39:45, Andres Almiray wrote:
> I think ||= conveys the exact meaning of the operand whereas ?= is missing
> the : to properly indicate that's a shorthand for Elvis.
> ?:= would be a walrus sporting a pompaduor if you ask me ;-)
>
> -------------------------------------------
> Java Champion; Groovy Enthusiast
> http://jroller.com/aalmiray
> http://www.linkedin.com/in/aalmiray
Re: [PROPOSAL]new operator ?=
Posted by Andres Almiray <aa...@gmail.com>.
I think ||= conveys the exact meaning of the operand whereas ?= is missing
the : to properly indicate that's a shorthand for Elvis.
?:= would be a walrus sporting a pompaduor if you ask me ;-)
-------------------------------------------
Java Champion; Groovy Enthusiast
http://jroller.com/aalmiray
http://www.linkedin.com/in/aalmiray
--
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 Tue, Nov 22, 2016 at 3:30 PM, Sergei Egorov <bs...@gmail.com> wrote:
> +1 for ||=
>
> Very convenient operator, doesn't break readability (more or less)
>
> On Tue, Nov 22, 2016 at 4:25 PM Guillaume Laforge <gl...@gmail.com>
> wrote:
>
>> It's a feature that's often be requested.
>> I think Ruby's got an equivalent with ||=, and it's often the reference
>> people give when exploring our Elvis operator coming from a ruby background
>> in particular.
>> I've had several opportunities where I could've used this operator.
>> It might make for a nice addition.
>>
>> Guillaume
>>
>> On Tue, Nov 22, 2016 at 3:14 PM, Daniel Sun <re...@hotmail.com>
>> wrote:
>>
>> Hi all,
>>
>> Marcin Erdmann proposed the new operator ?=, e.g. a ?= "foo" is
>> equivalent of a = a ?: "foo".
>>
>> I like his idea, what do you think about it?
>>
>> Cheers,
>> Daniel.Sun
>>
>>
>>
>> --
>> View this message in context: http://groovy.329449.n5.
>> nabble.com/PROPOSAL-new-operator-tp5736886.html
>> Sent from the Groovy Dev mailing list archive at Nabble.com.
>>
>>
>>
>>
>> --
>> Guillaume Laforge
>> Apache Groovy committer & PMC Vice-President
>> Developer Advocate @ Google Cloud Platform
>>
>> Blog: http://glaforge.appspot.com/
>> Social: @glaforge <http://twitter.com/glaforge> / Google+
>> <https://plus.google.com/u/0/114130972232398734985/posts>
>>
>
Re: [PROPOSAL]new operator ?=
Posted by Andres Almiray <aa...@gmail.com>.
Mr.G. I'm afraid ?= is closer to ?. than ?: hence why "my vote" would be to
use ||=
-------------------------------------------
Java Champion; Groovy Enthusiast
http://jroller.com/aalmiray
http://www.linkedin.com/in/aalmiray
--
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 Tue, Nov 22, 2016 at 3:39 PM, Guillaume Laforge <gl...@gmail.com>
wrote:
> But Elvis operator users won't relate to ||=, whereas they see the analogy
> between ?: and ?=. It's still Elvis "?:-)"
>
> On Tue, Nov 22, 2016 at 3:30 PM, Sergei Egorov <bs...@gmail.com> wrote:
>
>> +1 for ||=
>>
>> Very convenient operator, doesn't break readability (more or less)
>>
>> On Tue, Nov 22, 2016 at 4:25 PM Guillaume Laforge <gl...@gmail.com>
>> wrote:
>>
>>> It's a feature that's often be requested.
>>> I think Ruby's got an equivalent with ||=, and it's often the reference
>>> people give when exploring our Elvis operator coming from a ruby background
>>> in particular.
>>> I've had several opportunities where I could've used this operator.
>>> It might make for a nice addition.
>>>
>>> Guillaume
>>>
>>> On Tue, Nov 22, 2016 at 3:14 PM, Daniel Sun <re...@hotmail.com>
>>> wrote:
>>>
>>> Hi all,
>>>
>>> Marcin Erdmann proposed the new operator ?=, e.g. a ?= "foo" is
>>> equivalent of a = a ?: "foo".
>>>
>>> I like his idea, what do you think about it?
>>>
>>> Cheers,
>>> Daniel.Sun
>>>
>>>
>>>
>>> --
>>> View this message in context: http://groovy.329449.n5.nabble
>>> .com/PROPOSAL-new-operator-tp5736886.html
>>> Sent from the Groovy Dev mailing list archive at Nabble.com.
>>>
>>>
>>>
>>>
>>> --
>>> Guillaume Laforge
>>> Apache Groovy committer & PMC Vice-President
>>> Developer Advocate @ Google Cloud Platform
>>>
>>> Blog: http://glaforge.appspot.com/
>>> Social: @glaforge <http://twitter.com/glaforge> / Google+
>>> <https://plus.google.com/u/0/114130972232398734985/posts>
>>>
>>
>
>
> --
> Guillaume Laforge
> Apache Groovy committer & PMC Vice-President
> Developer Advocate @ Google Cloud Platform
>
> Blog: http://glaforge.appspot.com/
> Social: @glaforge <http://twitter.com/glaforge> / Google+
> <https://plus.google.com/u/0/114130972232398734985/posts>
>
Re: [PROPOSAL]new operator ?=
Posted by Guillaume Laforge <gl...@gmail.com>.
But Elvis operator users won't relate to ||=, whereas they see the analogy
between ?: and ?=. It's still Elvis "?:-)"
On Tue, Nov 22, 2016 at 3:30 PM, Sergei Egorov <bs...@gmail.com> wrote:
> +1 for ||=
>
> Very convenient operator, doesn't break readability (more or less)
>
> On Tue, Nov 22, 2016 at 4:25 PM Guillaume Laforge <gl...@gmail.com>
> wrote:
>
>> It's a feature that's often be requested.
>> I think Ruby's got an equivalent with ||=, and it's often the reference
>> people give when exploring our Elvis operator coming from a ruby background
>> in particular.
>> I've had several opportunities where I could've used this operator.
>> It might make for a nice addition.
>>
>> Guillaume
>>
>> On Tue, Nov 22, 2016 at 3:14 PM, Daniel Sun <re...@hotmail.com>
>> wrote:
>>
>> Hi all,
>>
>> Marcin Erdmann proposed the new operator ?=, e.g. a ?= "foo" is
>> equivalent of a = a ?: "foo".
>>
>> I like his idea, what do you think about it?
>>
>> Cheers,
>> Daniel.Sun
>>
>>
>>
>> --
>> View this message in context: http://groovy.329449.n5.
>> nabble.com/PROPOSAL-new-operator-tp5736886.html
>> Sent from the Groovy Dev mailing list archive at Nabble.com.
>>
>>
>>
>>
>> --
>> Guillaume Laforge
>> Apache Groovy committer & PMC Vice-President
>> Developer Advocate @ Google Cloud Platform
>>
>> Blog: http://glaforge.appspot.com/
>> Social: @glaforge <http://twitter.com/glaforge> / Google+
>> <https://plus.google.com/u/0/114130972232398734985/posts>
>>
>
--
Guillaume Laforge
Apache Groovy committer & PMC Vice-President
Developer Advocate @ Google Cloud Platform
Blog: http://glaforge.appspot.com/
Social: @glaforge <http://twitter.com/glaforge> / Google+
<https://plus.google.com/u/0/114130972232398734985/posts>
Re: [PROPOSAL]new operator ?=
Posted by Sergei Egorov <bs...@gmail.com>.
+1 for ||=
Very convenient operator, doesn't break readability (more or less)
On Tue, Nov 22, 2016 at 4:25 PM Guillaume Laforge <gl...@gmail.com>
wrote:
> It's a feature that's often be requested.
> I think Ruby's got an equivalent with ||=, and it's often the reference
> people give when exploring our Elvis operator coming from a ruby background
> in particular.
> I've had several opportunities where I could've used this operator.
> It might make for a nice addition.
>
> Guillaume
>
> On Tue, Nov 22, 2016 at 3:14 PM, Daniel Sun <re...@hotmail.com>
> wrote:
>
> Hi all,
>
> Marcin Erdmann proposed the new operator ?=, e.g. a ?= "foo" is
> equivalent of a = a ?: "foo".
>
> I like his idea, what do you think about it?
>
> Cheers,
> Daniel.Sun
>
>
>
> --
> View this message in context:
> http://groovy.329449.n5.nabble.com/PROPOSAL-new-operator-tp5736886.html
> Sent from the Groovy Dev mailing list archive at Nabble.com.
>
>
>
>
> --
> Guillaume Laforge
> Apache Groovy committer & PMC Vice-President
> Developer Advocate @ Google Cloud Platform
>
> Blog: http://glaforge.appspot.com/
> Social: @glaforge <http://twitter.com/glaforge> / Google+
> <https://plus.google.com/u/0/114130972232398734985/posts>
>
Re: [PROPOSAL]new operator ?=
Posted by Guillaume Laforge <gl...@gmail.com>.
It's a feature that's often be requested.
I think Ruby's got an equivalent with ||=, and it's often the reference
people give when exploring our Elvis operator coming from a ruby background
in particular.
I've had several opportunities where I could've used this operator.
It might make for a nice addition.
Guillaume
On Tue, Nov 22, 2016 at 3:14 PM, Daniel Sun <re...@hotmail.com> wrote:
> Hi all,
>
> Marcin Erdmann proposed the new operator ?=, e.g. a ?= "foo" is
> equivalent of a = a ?: "foo".
>
> I like his idea, what do you think about it?
>
> Cheers,
> Daniel.Sun
>
>
>
> --
> View this message in context: http://groovy.329449.n5.
> nabble.com/PROPOSAL-new-operator-tp5736886.html
> Sent from the Groovy Dev mailing list archive at Nabble.com.
>
--
Guillaume Laforge
Apache Groovy committer & PMC Vice-President
Developer Advocate @ Google Cloud Platform
Blog: http://glaforge.appspot.com/
Social: @glaforge <http://twitter.com/glaforge> / Google+
<https://plus.google.com/u/0/114130972232398734985/posts>