Skip to content

Commit ce9d225

Browse files
committed
Document how to make a kwarg's type explicit.
[ci-skip]
1 parent b9dc4c9 commit ce9d225

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

doc/manual/functions.rst

+10-4
Original file line numberDiff line numberDiff line change
@@ -476,19 +476,25 @@ Keyword argument default values are evaluated only when necessary
476476
left-to-right order. Therefore default expressions may refer to
477477
prior keyword arguments.
478478

479+
The types of keyword arguments can be made explicit as follows:
480+
481+
function f(;x::Int64=1)
482+
###
483+
end
484+
479485
Extra keyword arguments can be collected using ``...``, as in varargs
480486
functions::
481487

482-
function f(x; y=0, args...)
488+
function f(x; y=0, kwargs...)
483489
###
484490
end
485491

486-
Inside ``f``, ``args`` will be a collection of ``(key,value)`` tuples,
492+
Inside ``f``, ``kwargs`` will be a collection of ``(key,value)`` tuples,
487493
where each ``key`` is a symbol. Such collections can be passed as keyword
488-
arguments using a semicolon in a call, e.g. ``f(x, z=1; args...)``.
494+
arguments using a semicolon in a call, e.g. ``f(x, z=1; kwargs...)``.
489495
Dictionaries can also be used for this purpose.
490496

491-
In addition, one can also pass ``(key,value)`` tuples, or any iterable
497+
One can also pass ``(key,value)`` tuples, or any iterable
492498
expression (such as a ``=>`` pair) that can be assigned to such a
493499
tuple, explicitly after a semicolon. For example, ``plot(x, y;
494500
(:width,2))`` and ``plot(x, y; :width => 2)`` are equivalent to

0 commit comments

Comments
 (0)