Skip to content

Instantly share code, notes, and snippets.

@kklimuk
Created October 10, 2017 04:06
Show Gist options
  • Save kklimuk/a09d3c269499b2cb537de24d5b7095ad to your computer and use it in GitHub Desktop.
Save kklimuk/a09d3c269499b2cb537de24d5b7095ad to your computer and use it in GitHub Desktop.
class Foo
def call
'hi'
end
end
foo = proc { 'hi' }
Foo.new.call # 'hi'
foo.call # 'hi'
class Sayer
def initialize(word_giver)
@word_giver = word_giver
end
def say
puts @word_giver.call
end
end
# They're the same!
Sayer.new(Foo.new).say
Sayer.new(foo).say
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment