Document required keyword argument syntax [ci skip]

Fixes [Bug #8952]
This commit is contained in:
Jeremy Evans 2019-07-19 09:58:20 -07:00
Родитель 57b7bfad9e
Коммит 71d21f3c75
1 изменённых файлов: 11 добавлений и 0 удалений

Просмотреть файл

@ -398,6 +398,17 @@ When calling a method with keyword arguments the arguments may appear in any
order. If an unknown keyword argument is sent by the caller an ArgumentError
is raised.
To require a specific keyword argument, do not include a default value
for the keyword argument:
def add_values(first:, second:)
first + second
end
add_values
# ArgumentError (missing keywords: first, second)
add_values(first: 1, second: 2)
# => 3
When mixing keyword arguments and positional arguments, all positional
arguments must appear before any keyword arguments.