...
Code Block | ||
---|---|---|
| ||
doesnotexist.defaultsTo(x); // returns the value of x
doesnotexist.defaultsTo([]); // returns the empty array
doesnotexist.defaultsTo([], "doesnotexist was null"); // returns the empty array and writes a message to log |
The operator is most often used to guard against null values.
...