November 2017
Intermediate to advanced
162 pages
4h 8m
English
When there is a need to provide a default value, the ?= operator can be used. The following code shows its use:
A ?= "aval"
If A is set before the preceding code is called, it retains its previous value; if A has not been previously set, it is set to aval. Basically, the ?= operator assigns a new value to a variable if one has not already been set.
Note that if there are multiple ?= assignments to a single variable, the first of these is used. For example, we may have the following:
A ?= "aval"A ?= "change"
The variable A has the value aval. However, if we have A previously set, then it is used. For example:
A = "before"A ?= "aval"A ?= "change"
The A variable is kept as before.
Read now
Unlock full access