Skip to content

Instantly share code, notes, and snippets.

@rebeccaskinner
Created March 21, 2013 16:20
Show Gist options
  • Save rebeccaskinner/5214338 to your computer and use it in GitHub Desktop.
Save rebeccaskinner/5214338 to your computer and use it in GitHub Desktop.
#!/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