Is it possible to write a parametric type with default type?
struct Point{T}
x::T
y::T
end
struct Foo
a::Point{Float64}
b::Point # should be the default type: Point{Float64}
c::Point{Int}
end
Is it possible to write a parametric type with default type?
struct Point{T}
x::T
y::T
end
struct Foo
a::Point{Float64}
b::Point # should be the default type: Point{Float64}
c::Point{Int}
end
No, not as written. b::Point
already means something: it means b
can have a type which is Point{T}
for any T
. You could consider doing:
const PointF = Point{Float64}
struct Foo
b::PointF
...
which is only slightly more verbose.