-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document how to make a kwarg's type explicit.
[ci-skip]
- Loading branch information
Showing
1 changed file
with
10 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -476,19 +476,25 @@ Keyword argument default values are evaluated only when necessary | |
left-to-right order. Therefore default expressions may refer to | ||
prior keyword arguments. | ||
|
||
The types of keyword arguments can be made explicit as follows: | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
tkelman
Contributor
|
||
|
||
function f(;x::Int64=1) | ||
### | ||
end | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
Extra keyword arguments can be collected using ``...``, as in varargs | ||
functions:: | ||
|
||
function f(x; y=0, args...) | ||
function f(x; y=0, kwargs...) | ||
### | ||
end | ||
|
||
Inside ``f``, ``args`` will be a collection of ``(key,value)`` tuples, | ||
Inside ``f``, ``kwargs`` will be a collection of ``(key,value)`` tuples, | ||
where each ``key`` is a symbol. Such collections can be passed as keyword | ||
arguments using a semicolon in a call, e.g. ``f(x, z=1; args...)``. | ||
arguments using a semicolon in a call, e.g. ``f(x, z=1; kwargs...)``. | ||
Dictionaries can also be used for this purpose. | ||
|
||
In addition, one can also pass ``(key,value)`` tuples, or any iterable | ||
One can also pass ``(key,value)`` tuples, or any iterable | ||
expression (such as a ``=>`` pair) that can be assigned to such a | ||
tuple, explicitly after a semicolon. For example, ``plot(x, y; | ||
(:width,2))`` and ``plot(x, y; :width => 2)`` are equivalent to | ||
|
I guess this should end with
::
?