#94 - Safe Navigation Operator

+200 points
Contributed by: Ankush Sarsewar

Implement the method getAccountBillingCityWithSafeNavigation, which accepts a list of accounts as an input and returns the BillingCity in upper case of the first account in the list. Use the Safe Navigation (?.) to ensure null is returned in case the BillingCity is null.

Given the following test code:

List<Account> acts = new ListList<Account>();
acts.add(new Account(Name = 'Acme', BillingCity = 'Chicago'));
acts.add(new Account(Name = 'Dove', BillingCity = 'Boston'));
String result = getAccountBillingCityWithSafeNavigation(acts);

result should be 'CHICAGO'

Discuss this problem on the ApexSandbox.io Trailblazer Community Group

Loading...