Posts

Showing posts with the label Null coalescing

Salesforce Fact #865 | Null coalescing in JS

Image
We have null coalescing operator in JS as well and it works only with null and undefined. Attached is the screenshot.

Salesforce Fact #864 | Using null coalescing and safe navigation together in Apex

Image
Suppose we have a Map<String, List<Id>> and based on some condition checks, we need to add or update the list as part of the map value with respect to key value. We can do the check a bit differently using both safe navigation and null coalescing operator. In this example, we are storing the list of Ids in map specific to object key prefix. Attached are the screenshots.