Created
November 28, 2010 18:34
-
-
Save hgmnz/719171 to your computer and use it in GitHub Desktop.
Object#method
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
ree-1.8.7-2010.02 > some_string = "hi there" | |
=> "hi there" | |
ree-1.8.7-2010.02 > some_string.capitalize | |
=> "Hi there" | |
ree-1.8.7-2010.02 > some_method = some_string.method :capitalize | |
=> #<Method: String#capitalize> | |
ree-1.8.7-2010.02 > some_method.call | |
=> "Hi there" | |
ree-1.8.7-2010.02 > String.class_eval { remove_method(:capitalize) } | |
=> String | |
ree-1.8.7-2010.02 > some_string.capitalize | |
NoMethodError: undefined method `capitalize' for "hi there":String | |
from (irb):18 | |
ree-1.8.7-2010.02 > some_method.call | |
=> "Hi there" | |
ree-1.8.7-2010.02 > unbound = some_method.unbind | |
=> #<UnboundMethod: String#capitalize> | |
ree-1.8.7-2010.02 > unbound.call | |
NoMethodError: undefined method `call' for #<UnboundMethod: String#capitalize> | |
from (irb):23 | |
ree-1.8.7-2010.02 > another_string = "bye bye" | |
=> "bye bye" | |
ree-1.8.7-2010.02 > another_string.capitalize | |
NoMethodError: undefined method `capitalize' for "bye bye":String | |
from (irb):26 | |
ree-1.8.7-2010.02 > rebound = unbound.bind(another_string) | |
=> #<Method: String#capitalize> | |
ree-1.8.7-2010.02 > rebound.call | |
=> "Bye bye" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment