#SalesforceSpring24 – Introducing Null Coalescing Operator in Apex

#1MinuteTip #SalesforceSpring24 With Null coalescing operator “??”, the operator returns the left-hand argument if the left-hand argument isn’t null. Otherwise, it returns the right-hand argument.

Similar to the safe navigation operator (?.), the null coalescing operator (??) replaces verbose and explicit checks for null references in code.

Product Area: Apex


Integer notNullReturnValue = (anInteger != null) ? anInteger : 100;


Integer notNullReturnValue = anInteger ?? 100;

References & Useful URLs

  • For Related Spring ’24 Release Note Article – Click Here

Want to Receive these Tips in your Inbox?

Finding it overwhelming to keep pace with Salesforce’s new release features? Try our “1 Day 1 Tip 1 Minute” emails, where you are going to get 1 tip every day that won’t take more than a minute to read. To find out more and subscribe please click here.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top
Introducing All Access Pass