Notice also that convert(t, "4") just returns a SubString{ASCIIString} and
not a Uint64.
On Tuesday, June 17, 2014 7:37:59 PM UTC+1, Jack Holland wrote:
>
> Does anyone have an explanation for why a type variable (e.g. Uint64) acts
> differently when accessed in an array (e.g. [Uint64]) than by itself?
> Here's some sample code to show what I mean:
>
> import Base.convert
>
> function convert{T1<:Integer, T2<:String}(totype::Type{T1}, value::T2)
> println("convert: $totype, $value")
> #parseint(totype, value)
> end
>
> for t in [Uint64]
> convert(t, "4")
> convert(Uint64, "4")
> println(t)
> end
>
> This code prints:
>
> convert: Uint64, 4
> Uint64
>
> As you can see, only the second call to `convert` prints the message. Why
> isn't the convert method defined above called twice? Why does placing
> Uint64 in an array change its behavior? Is there something I'm missing here
> about how for loops or types work in Julia? Is this a bug or intended
> behavior?
>