Skip to content

Instantly share code, notes, and snippets.

@maxim
Created November 4, 2012 22:51
Show Gist options
  • Select an option

  • Save maxim/4014181 to your computer and use it in GitHub Desktop.

Select an option

Save maxim/4014181 to your computer and use it in GitHub Desktop.
Ruby's merge calls to_hash
>> obj = Object.new
=> #<Object:0x007ff6bd6b07e0>
>> def obj.to_hash; { bar: 'bar' } end
=> nil
>> { foo: 'foo' }.merge(obj)
=> {:foo=>"foo", :bar=>"bar"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment