Keyword Arguments

  • ruby 2.0: keyword arguments must have default values.
  • ruby 2.1+: required keyword arguments are allowed to have no default values
def any_method(arg1:, arg2:, arg3:)
  # some code
end

any_method(arg3: "three", arg2: "two", arg1:"one")
# the order of the arguments doesn't matter but the values are required

Reference

results matching ""

    No results matching ""