What is the -> (stab) operator in Ruby? [duplicate]

It’s the Ruby 1.9 “stabby lambda” operator. For example, see this article from 2008.

Nutshell:

> foo2 = ->(arg) { arg * 2 }
> foo2.call "now"
 => nownow

Note the lack of space between -> and (arg), that’s intentional.

Leave a Comment