What does -> mean in Ruby
ruby, ruby-on-rails
Solution
It is a lambda literal. Check this example:
> plus_one = ->(x){x+1}
=> #<Proc:0x9fbaa00@(irb):3 (lambda)>
> plus_one.call(3)
=> 4
A lambda literal is a constructor for Proc. A `Proc` is a way to have a block of code assigned to a variable. After this, you can call your block of code again, with different arguments, as many times as you wish.
This is how you can pass a "function" as parameter in ruby. In many languages, you could pass a reference to a function. In ruby, you can pass a Proc object.
Problem
I've seen that in spree commerce. ``` go_to_state :confirm, if: ->(order) { order.confirmation_required? } ``` So what'll do that symbol?