diff --git a/pep-0695.rst b/pep-0695.rst index 4ecada5a0..182a3eb52 100644 --- a/pep-0695.rst +++ b/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 ----