jashkenas/coffee-script — Issue #2170: Existential operator in assignments
Author: jussiry
Created: 2012-03-03 11:44:16+00:00
State: open

There is an assignment operator that assigns new value only if variable is null or undefined:

foo ?= bar

But what about the opposite? Operator that would assign only if the var already exists, e.g.

foo? = bar

Above currently throws exception. Is there any good way to write this, without repeating the code, e.g.

foo = bar if foo?

?