Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # From ruby koans (http://rubykoans.com) - specifically about_hashes.rb
- # Specifically def test_default_value_is_the_same_object
- # Line 93
- # This would be how I would run it in irb
- hash = Hash.new([])
- hash[:one] << "uno"
- hash[:two] << "dos"
- hash[:one] # => ["uno", "dos"]
- hash[:two] # => ["uno", "dos"]
- hash[:three] # => ["uno", "dos"]
- newHash = Hash.new
- newHash[:one] << "uno" # NoMethodError : undefined method '<<' for nil:NilClass
Advertisement
Add Comment
Please, Sign In to add comment