Conditional assignment operator proposal

What would be easier then

val a = mapOf<String, String>()["key"]?.let { it }

which produce the same result?

In cabman’s version the first let expression that evaluates to non null is assigned to x. The same as in my original example. I am doing such constructs often myself, but I don’t like them that much.

not exactly, your code sets null, ?= will not set at all when null

So you want the field to be not set at declaration site? It is prohibited by Kotlin.

Also side effects are not a good approach in general they are even less desirable in setters.

If you really need to avoid call to setter do x?.let { x = ... }. Just a bit more then extra language constant you proposing to workaround otherwise bad design.

for android very need simple construction for

if (a!=b)
a = b

to reduce setters and redrawing thread