Le dimanche 20 décembre 2015 à 07:43 -0800, Lutfullah Tomak a écrit :
> Now I get error for
> b[1]=T1(1)
> too.
>
> All in all, having x instead of x::Int in the definition of
> Base.convert assignment to array entries give error.
The problem is that defining
Base.convert(::Type{T1}, x) = T1(x)
implies that convert(T1, a), instead of simply returning x as it
should, tries to create a T1 object with its x member equal to a. This
is where the error comes from. To see it, try:
a = T1(1)
T1(a)
One of the ways to fix this is to add this method:
Base.convert(::Type{T1}, x::T1) = x
Regards