Try the following:

b = [a[i]::Int64 for i=1:3]

This is hinting the type, see
http://docs.julialang.org/en/latest/manual/performance-tips/#annotate-values-taken-from-untyped-locations

-Jacob


On Fri, Feb 14, 2014 at 12:04 PM, Nico <[email protected]> wrote:

> When I build an array using a comprehension as follows:
>
>         a = [i for i=1:3]
>
> its type is 3-element Array{Int64,1}.
>
>
> However, when I build a second array as:
>
>         b = [a[i] for i=1:3]
>
> its type is 3-element Array{Any,1} instead of Array{Int64,1}.
>
>
> How can I build b so that it preserves the type of a?
>

Reply via email to