Safe Navigation Operator (&.)

A good way to use safe navigation operator (&.) in your code ✨

Code snippet 📌

if client.present? && client.address.present?
  @city = client.address.city
end

# with safe navigation operator (&.)
@city = client&.address&.city

Read more 🔖 - http://mitrev.net/ruby/2015/11/13/the-operator-in-ruby/