Elvis setter

Hi all,

Elvis operator is well spread and intensively used, as far as I can testify.

I would have a handy idea, to solve a very very common case:

mystruct.myvalue = mystruct.myvalue ?: 0;

We could have an “Elvis setter” to simplify default value like this:

mystruct.myvalue ?= 0;

Cheers

Nice idea!

1 Like