Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
What do you think gets printed as Exhibit F?
#! /usr/bin/ruby
def print_call_and_return(string, &block)
puts string
block.call unless !block
"return"
end
puts "=== exhibit A ==="
print_call_and_return("parameter")
puts "=== exhibit B ==="
a = print_call_and_return("parameter")
puts a
puts "=== exhibit C ==="
puts print_call_and_return("parameter")
puts "=== exhibit D ==="
print_call_and_return("parameter") do
puts "block"
end
puts "=== exhibit E ==="
a = print_call_and_return("parameter") do
puts "block"
end
puts a
puts "=== exhibit F ==="
puts print_call_and_return("parameter") do
puts "block"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.