← Back to Ruby Operators

Arbitrary Keyword Arguments

The double asterisk symbol (**) is used to denote arbitrary keyword arguments in a method definition. These are also referred to as kwargs (pronounced phonentically).

Here is an example of defining a method that accepts arbitrary keyword arguments.

def some_method(**kwargs)
  if kwargs[:user_id]
    puts "User ID: #{kwargs[:user_id]}"
  end
end

References