Skip to content

Instantly share code, notes, and snippets.

@wejn
Created January 31, 2012 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wejn/1709758 to your computer and use it in GitHub Desktop.
Save wejn/1709758 to your computer and use it in GitHub Desktop.
Ruby Koans - About Hashes - why breaking out the hash is necessary?
def test_changing_hashes
hash = { :one => "uno", :two => "dos" }
hash[:one] = "eins"
expected = { :one => "eins", :two => "dos" }
assert_equal true, expected == hash
assert_equal true, { :one => "eins", :two => "dos" } == hash
# Bonus Question: Why was "expected" broken out into a variable
# rather than used as a literal?
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment