I've seen that in spree commerce.
go_to_state :confirm, if: ->(order) { order.confirmation_required? }
So what'll do that symbol?
In Ruby 1.9 you can use the stab operator ->
to create a lambda.
l1 = lambda { puts "I'm a lambda" }
l2 = -> { puts "I'm a lambda" }
The operator also accept arguments.
l1 = lambda(name) { puts "I'm a #{name}" }
l2 = ->(name) { puts "I'm a #{name}" }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With