Last active
May 6, 2019 01:51
-
-
Save georgebonnr/5914904 to your computer and use it in GitHub Desktop.
Ruby errors
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
# Ruby-doc documentation from http://ruby-doc.org/core-2.0/Object.html#method-i-class | |
guy = "Bob" | |
guy.define_singleton_method(:hello) { "#{self}: Hello there!" } | |
guy.hello #=> "Bob: Hello there!" | |
# ------------------------------------------------------------------------------ | |
# Here is what I get on my machine: | |
guy = "Bob" | |
# ==> "Bob" | |
guy.define_singleton_method(:hello) { "#{self}: Hello there!" } | |
# =NoMethodError: undefined method `define_singleton_method' for "Bob":String | |
# = from (irb):71 | |
guy.hello | |
# =NoMethodError: undefined method `hello' for "Bob":String | |
# = from (irb):72 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment