Inference is limited at global scope because the variable type might
change. See performance tips in the manual
That said, if you know the output type ahead of time, you can
do: a=Float64[i+2.5-b for i=1:10]

On Sun, Jan 11, 2015 at 10:33 PM, <[email protected]> wrote:

> A new user here. I am wondering why a non-predefined array get a type
> {Any}? also why some mathematical functions don't work on it?
>
> if I define an array "a" as:
> a=[i for i=1:10]
> then it is automatically {Int64}. If change it to:
> a=[i+2.5 for i=1:10]
> then it is automatically {Float64} as expected. However, when I define an
> integer, say: b=3 and use it in the array generation:
> a=[i+2.5-b for i=1:10]
> then it becomes {Any}. Why it is still not Float64?
>
> I came to this as I was trying to take a log of an array, and it was
> complaining that it can't operate on type {Any}.
>
> thanks,
>

Reply via email to