In my humble personal experience, I confirm I would have find it useful
when properties are involved, i.e.:
foo.property ?= 'defaultValue'
instead of
foo.property = foo.property?: 'defaultValue'
or the lengthy:
def a = foo.property
foo.property = a?: 'defaultValue'
Not to say in case of nested properties:
foo.bar.baz.property = foo.bar.baz.property?: 'defaultValue'
Mauro
Il 23/11/2016 09:15, Cédric Champeau ha scritto:
I would say +1 to ?= . There are a few cases where I would have used
it. Typically, configuring some defaults after the fact. I'm not
saying this is a good pattern in general, but it can come handy:
void finalize(Config config) {
config.with {
foo ?= 'foo'
bar ?= 'bar'
baz ?= 'baz'
}
}