In Rails, you can do hash.try(:[], :key) which helps if hash is potentially nil. Is there an equivalent version for using the new Ruby 2.3
hash.try(:[], :key)
hash
nil
A rather more legible way to use the safe navigation operator than using hash&.[](:slug) is to use the fetch method:
hash&.[](:slug)
fetch
hash&.fetch(:slug)
If your key may not be defined, you can use the second argument as a default:
hash&.fetch(:slug, nil)