Skip to content

Commit efe4fa6

Browse files
bicycle1885KristofferC
authored andcommitted
fix description of kwargs... (#28757)
* fix description of kwargs... * clarify the key type of dicts passed as kwargs (cherry picked from commit 3a54c14)
1 parent 5e16f5a commit efe4fa6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

doc/src/manual/functions.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,10 @@ function f(x; y=0, kwargs...)
541541
end
542542
```
543543

544+
Inside `f`, `kwargs` will be a key-value iterator over a named tuple. Named
545+
tuples (as well as dictionaries with keys of `Symbol`) can be passed as keyword
546+
arguments using a semicolon in a call, e.g. `f(x, z=1; kwargs...)`.
547+
544548
If a keyword argument is not assigned a default value in the method definition,
545549
then it is *required*: an [`UndefKeywordError`](@ref) exception will be thrown
546550
if the caller does not assign it a value:
@@ -552,9 +556,6 @@ f(3, y=5) # ok, y is assigned
552556
f(3) # throws UndefKeywordError(:y)
553557
```
554558

555-
Inside `f`, `kwargs` will be a named tuple. Named tuples (as well as dictionaries) can be passed as
556-
keyword arguments using a semicolon in a call, e.g. `f(x, z=1; kwargs...)`.
557-
558559
One can also pass `key => value` expressions after a semicolon. For example, `plot(x, y; :width => 2)`
559560
is equivalent to `plot(x, y, width=2)`. This is useful in situations where the keyword name is computed
560561
at runtime.

0 commit comments

Comments
 (0)