-
The new lambda literal syntax is preferred in Ruby 1.9.
# BAD lambda = lambda { |a, b| a + b } # GOOD lambda = ->(a, b) { a + b }
-
Always use
#call
to execute a lambda:add = lambda { |a, b| a + b } # BAD add.(1, 2) # BAD add[1, 2] # ACCEPTABLE (use your judgement in context) add.call 1, 2 # GOOD add.call(1, 2)
Created
November 20, 2012 17:48
-
-
Save sam/4119560 to your computer and use it in GitHub Desktop.
Lambda syntax guidelines
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment