Guest User

Untitled

a guest
Apr 20th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. def append(object)
  2. object << "hello"
  3. end
  4.  
  5. a = [ 1 ] # array
  6. b = "yo ho ho" # string
  7. c = StringIO.new("yo ho ho") # string IO; still responds to the << method
  8. d = { "hi" => "there" } # hash; does not respond to << method
  9.  
  10. append a # works
  11. append b # works
  12. append c # works
  13. append d # blows up since there is no << method on hashes
Add Comment
Please, Sign In to add comment