David - Musings of an SRE

Equivalent of try() for hashes? - Ruby

To do a try() on hashes, its as simple as:

  # to get data['something_value']
  @item = @model.try(:data).try(:[], 'something_value']

2021 Update

References: