Created
March 21, 2013 16:20
-
-
Save rebeccaskinner/5214338 to your computer and use it in GitHub Desktop.
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 | |
# Create a simple function to call a lambda | |
def testCall f | |
f.call 3 | |
end | |
# Call testCall with a lambda, this version works | |
testCall(lambda do |x| puts "test, x = #{x}" end) | |
# Call testCall again with an intermediate variable, this version also works | |
x = lambda do |x| puts "test, x = #{x}" end | |
testCall x | |
# call testCall with a lambda, this fails because function application has a higher precedence than binding a block? | |
testCall lambda do |x| puts "test, x = #{x}" end | |
# call testCall with a lambda, this fails for mysterious reasons? | |
testCall (lambda do |x| puts "test, x = #{x}" end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment