It seems there is no difference between these two expressions.
h = {a: 1, b: 2}
h.merge({c: 3, d: 4})
h.merge(c: 3, d: 4)
Is there a problematic case if I omit the curly braces when using Hash as an argument?
No, there is no difference between both versions.
Furthermore, it is a common Ruby/Rails idiom to omit the curly brackets when the hash is the last argument to a method. Compare the following common examples:
validates :foo, { presence: true }
validates :foo, presence: true
link_to "Foos", foo_path, { class: "foo" }
link_to "Foos", foo_path, class: "foo"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With