I agree, fetch is the way to go. It is more verbose, but does not any magic/core extensions.
If you want two have more magic, consider using the andand gem <https://github.com/raganwald/andand> or the egonil refinement <http://rubyzucker.info/#egonil> On 27.07.2014 19:52, Daniel Evans wrote: > You can use fetches or default block to clean up that code without > doing a dangerous monkey-patch like you are suggesting. > > Consider: > hash.fetch(:data, {}).fetch(:details, {})[:id] -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.
