Created
September 1, 2012 06:02
-
-
Save knewter/3565125 to your computer and use it in GitHub Desktop.
quickie explanation of #method
This file contains hidden or 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
class Foo | |
def initialize baz | |
@baz = baz | |
end | |
def bar | |
puts @baz | |
end | |
end | |
class Wiggy | |
def initialize(disconnected_method) | |
@disconnected_method = disconnected_method | |
end | |
def run | |
@disconnected_method.call | |
end | |
end | |
f = Foo.new("tad") | |
w = Wiggy.new(f.method(:bar)) | |
w.run | |
#=> "tad" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment