I am having some issues understanding the concept of parametric constructors in Julia. I am looking at the standard example in the Julia docs:
struct Point{T<:Real}
x::T
y::T
end
To my understanding, this means I can generate a Point-datatype with an input that is subtype of Real, i.e., AbstractFloat, AbstractIrrational, ..., Integer, Rational, ..., StatsBase.TestStat.
However, both of the examples below result in errors:
Point(Integer(12))
Point(Rational(12))
Why does the above fail given that both integer and rational are subtypes of real?
<:, to my understanding I am making sure that the input can be any subtype ofReal(?)Point{Real}isn't a Subtype ofReal. When you declare, you have to declare it like this:p = Point{Integer}(12,12)Point{Real}is a subtype ofReal? I am only assuming thatIntegerandRationalare subtypes ofReal- or am I misunderstanding something here?