Last Updated: February 25, 2016
·
1.15K
· glucero

Proc#[] is an alias for Proc#call

lambda:

doubler = ->(i) { i + i }

'normal' way of calling a proc:

doubler.call(4)
  => 8

added in 1.9:

doubler.(4)
  => 8

using array element access style syntax:

doubler[4]
  => 8

this also works (but will confuse everyone that sees it!):

doubler === 4
  => 8

1 Response
Add your response

Wow Ruby can make no sense sometimes. :P

over 1 year ago ·