Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #I can't say much about the subtle differences. However, I can point out that Ruby #1.9 now allows optional parameters for lambdas and blocks.
- #Here's the new syntax for the stabby lambdas under 1.9:
- stabby = ->(msg='inside the stabby lambda') { puts msg }
- #Ruby 1.8 didn't have that syntax. Neither did the conventional way of declaring #blocks/lambdas support optional args:
- # under 1.8
- l = lambda { |msg = 'inside the stabby lambda'| puts msg }
- #SyntaxError: compile error
- #(irb):1: syntax error, unexpected '=', expecting tCOLON2 or '[' or '.'
- #Ruby 1.9, however, supports optional arguments even with the old syntax:
- l = lambda { |msg = 'inside the regular lambda'| puts msg }
- #=> #<Proc:0x0e5dbc@(irb):1 (lambda)>
- l.call
- #=> inside the regular lambda
- l.call('jeez')
- #=> jeez
Add Comment
Please, Sign In to add comment