Skip to content

Instantly share code, notes, and snippets.

@Sihui
Created April 23, 2017 17:45
Show Gist options
  • Save Sihui/812a47cad138874b83f6bd3a700a9d3c to your computer and use it in GitHub Desktop.
Save Sihui/812a47cad138874b83f6bd3a700a9d3c to your computer and use it in GitHub Desktop.
For [Code Block, Proc, Lambda, and Closure in Ruby]()
# Example: passing arguments
def ten_plus
puts 'before yield'
yield(10)
puts 'after yield'
end
ten_plus do |num|
puts(num + 100)
end
# the above code will prints out
# before yield
# 110
# after yield
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment