re: Are there functions similar to Ruby's `dig` in other languages? VIEW POST

FULL DISCUSSION
 

In Java (version 8 and onward) this can be done using Optional

String phoneNumber = Optional.ofNullable(list.get(0))
                             .map(Order::getCustomer)
                             .map(Customer::getPhone)
                             .orElse(null);
code of conduct - report abuse