Created
November 29, 2009 16:59
-
-
Save fletcherm/244979 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment