I simply typed the following line of code in a Rails application:
scope :for_uid, ->(external_id) { where(external_id: external_id) }
What does operator -> mean? This is difficult for Google.
->
This is syntactic sugar.
->(external_id) { where(external_id: external_id) }
equally:
lambda { |external_id| where(external_id: external_id) }
new lambda notation . This syntax was introduced in ruby 1.9 and is used to define unnamed functions.
In your example, this is the area defined by an unnamed function.
The -> operator was introduced in Ruby 1.9 as a shorthand syntax for the old lambda function. It works almost identically to the lambda function, but allows you to specify parameters outside the block:
lambda
lambda {|param| puts param } # becomes -> (param) { puts params }