def test_changing_hashes hash = { :one => "uno", :two => "dos" } hash[:one] = "eins" expected = { :one => "eins", :two => "dos" } assert_equal expected, hash # Bonus Question: Why was "expected" broken out into a variable # rather than used as a literal? end Can anyone help with the bonus question? From searching Google, I read that the reason: assert_equal { :one => "eins", :two => "dos" }, hash gives an error is th…
Here are some of the variants:
method({ ... }) # hash
method { ... } # block, even though a hash would be possible.
method = { ... } # hash
method a, b, :c => d # implicit hash
method a, b { ... } # SyntaxError
method(a, b) { ... } # block
Only #2 in that list is really a problem, because there are situations where you'd legitimately like to use both.