Created
March 4, 2013 15:12
-
-
Save tomwhoiscontrary/5082896 to your computer and use it in GitHub Desktop.
What do you think gets printed as Exhibit F?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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