The ?? Operator returns the left-hand argument if the left-hand argument isn't null. Otherwise, it returns the right-hand argument.
// Left operand SOQL is empty, return defaultAccount from right operand:
Ex :
Account defaultAccount = new Account(name = 'Acme');
Account a = [SELECT Id FROM Account WHERE Id = '001000000FAKEID'] ?? defaultAccount;
Assert.areEqual(defaultAccount, a);
No comments:
Post a Comment