Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def append(object)
- object << "hello"
- end
- a = [ 1 ] # array
- b = "yo ho ho" # string
- c = StringIO.new("yo ho ho") # string IO; still responds to the << method
- d = { "hi" => "there" } # hash; does not respond to << method
- append a # works
- append b # works
- append c # works
- append d # blows up since there is no << method on hashes
Add Comment
Please, Sign In to add comment