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.
More Related Contents:
- How to write a switch statement in Ruby
- Ruby class instance variable vs. class variable
- Ruby Gem install Json fails on Mavericks and Xcode 5.1 – unknown argument: ‘-multiply_definedsuppress’
- Blocks and yields in Ruby
- Best way to require all files from a directory in ruby?
- “for” vs “each” in Ruby
- How to make a HTTP request using Ruby on Rails?
- Continuously read from STDOUT of external process in Ruby
- String concatenation vs. interpolation in Ruby
- Ruby’s double colon (::) operator usage differences
- When to use RSpec let()?
- How can I use Ruby to colorize the text output to a terminal? [closed]
- How to create a file in Ruby
- What is the “=~” operator in Ruby?
- Ruby send JSON request
- In Ruby is there a way to overload the initialize constructor?
- Printing the source code of a Ruby block
- Why does Ruby’s ‘gets’ includes the closing newline?
- Ruby multiline block without do end
- Error to install Nokogiri on OSX 10.9 Maverick?
- `&:views_count` in `Post.published.collect(&:views_count)` [duplicate]
- Ruby: Easiest Way to Filter Hash Keys?
- How to assign hash[‘a’][‘b’]= ‘c’ if hash[‘a’] doesn’t exist?
- Why does white-space affect ruby function calls?
- What is the difference between Raising Exceptions vs Throwing Exceptions in Ruby?
- List of installed gems?
- What are those pipe symbols for in Ruby?
- Ruby’s yield feature in relation to computer science
- Why isn’t current directory on my Ruby path? [duplicate]
- Iterate over Ruby Time object with delta