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 🔖