Skip to content

Commit

Permalink
add help text for the where keyword (#22177)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored and KristofferC committed Jun 1, 2017
1 parent e36e412 commit ab771ef
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions base/docs/basedocs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,36 @@ to be set after construction. See `struct` and the manual for more information.
"""
kw"mutable struct"

"""
The `where` keyword creates a type that is an iterated union of other types, over all
values of some variable. For example `Vector{T} where T<:Real` includes all `Vector`s
where the element type is some kind of `Real` number.
The variable bound defaults to `Any` if it is omitted:
Vector{T} where T # short for `where T<:Any`
Variables can also have lower bounds:
Vector{T} where T>:Int
Vector{T} where Int<:T<:Real
There is also a concise syntax for nested `where` expressions. For example, this:
Pair{T, S} where S<:Array{T} where T<:Number
can be shortened to:
Pair{T, S} where {T<:Number, S<:Array{T}}
This form is often found on method signatures.
Note that in this form, the variables are listed outermost-first. This matches the
order in which variables are substituted when a type is "applied" to parameter values
using the syntax `T{p1, p2, ...}`.
"""
kw"where"

"""
ans
Expand Down

0 comments on commit ab771ef

Please sign in to comment.