Hi, I saw in Julia's tutorial about this:

julia> function foo()
         x::Int8 = 1000
         x
       end
foo (generic function with 1 method)

julia> foo()
-24

julia> typeof(ans)
Int8


I tried the type declaration in a terminal, in the main scope (not inside a 
function), and I got:

julia> x::Int8 = 3
ERROR: type: typeassert: expected Int8, got Int64

I would have expected *x* to be an *Int8*, rather than raising the 
assertion.

I also tried

julia> local x::Int8 = 3
3

julia> typeof(ans)
Int64

It's an *Int64*, not an *Int8*.

Is there a logic behind this behavior?


Reply via email to