Type: New Feature
Affects Version/s: None
Fix Version/s: None
Number of attachments :
I'd like to propose 'method apply and assign' operator.
We already have 'apply and assign' operators like:
By using those operators, we can make shorten expression:
On the other hand, we don't have the same way for method calls. This proposal introduces a shorthand way of apply and assign the result to itself for method calls in Groovy.
Introduce new operators '=.' or '=.' like
Comparison of .= and =.
'.=' is along with the other assign operators.
For example, based on this rule:
.= is interpreted in following way:
=. is based on a rule which implies under elvis operator.
is shorten by using elvis
is shorten to
IMHO, .= is better because it is easy to remind and has similarity of other assign operators.