📅  最后修改于: 2022-03-11 14:58:27.032000             🧑  作者: Mango
// Existing lengthy code checking for null fields
results = [SELECT Name FROM Account WHERE Id = :accId];
if (results.size() == 0) { // Account doesn't exist, isn't visible, was deleted, etc
return null;
}
return results[0].Name;
// New crisp code using the safe navigation operator
return [SELECT Name FROM Account WHERE Id = :accId]?.Name;