Skip to content

Instantly share code, notes, and snippets.

@lin
Last active August 29, 2015 14:15
Show Gist options
  • Select an option

  • Save lin/1454170664b6ba384303 to your computer and use it in GitHub Desktop.

Select an option

Save lin/1454170664b6ba384303 to your computer and use it in GitHub Desktop.
def hello str, &block
pre_str = str + " world!"
block.call pre_str
after_str = "say " + str
puts after_str
end
hello "hello" do |str|
puts "MC says #{str}"
end
hello "hello" do |str|
puts "YL says #{str}"
end
##### outputs
# MC says hello world!
# say hello
# YL says hello world!
# say hello
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment