Skip to content

Instantly share code, notes, and snippets.

@bion
Created January 26, 2015 06:24
Show Gist options
  • Select an option

  • Save bion/6abe02ceec9d99c85561 to your computer and use it in GitHub Desktop.

Select an option

Save bion/6abe02ceec9d99c85561 to your computer and use it in GitHub Desktop.
Ruby concepts 2
class Foo
def double_then_yield(num, &block)
block.call(num * 2)
end
end
foo = Foo.new
result = foo.double_then_yield 5 do |num|
num + 1
end
puts "result is #{result}" # result is 11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment