PEP 695: Edit for valid Julia Syntax (#3300)
This commit is contained in:
parent
70cf21146c
commit
c8336b7b49
18
pep-0695.rst
18
pep-0695.rst
|
@ -1495,16 +1495,22 @@ upper and lower bounds on a type.
|
|||
|
||||
.. code-block:: julia
|
||||
|
||||
// Generic struct; type parameter with upper and lower bounds
|
||||
struct StructA{T} where Int <: T <: Number
|
||||
# Generic struct; type parameter with upper and lower bounds
|
||||
# Valid for T in (Int64, Signed, Integer, Real, Number)
|
||||
struct Container{Int <: T <: Number}
|
||||
x::T
|
||||
end
|
||||
|
||||
// Generic function
|
||||
function func1{T <: Real}(v::Container{T})
|
||||
# Generic function
|
||||
function func1(v::Container{T}) where T <: Real end
|
||||
|
||||
// Alternate form of generic function
|
||||
function func2(v::Container{T} where T <: Real)
|
||||
# Alternate forms of generic function
|
||||
function func2(v::Container{T} where T <: Real) end
|
||||
function func3(v::Container{<: Real}) end
|
||||
|
||||
# Tuple types are covariant
|
||||
# Valid for func4((2//3, 3.5))
|
||||
function func4(t::Tuple{Real,Real}) end
|
||||
|
||||
Dart
|
||||
----
|
||||
|
|
Loading…
Reference in New Issue