I was playing around with type declarations and came across an 
counterintuitive result. I'm not sure if this is the intended behavior or 
not, but it certainly surprised me.

Consider the functions

*function f(x)*

       *y::Int*

       *y=x*2.0*

*end*

*function g(x)*

       *y::Int*

       *y=x*2.0*

       *y*

*end*

*julia> **f(1),g(1)*

*(2.0,2)*

I expected them to behave identically, always returning an Int. But clearly 
f returns a Float64.


It seems like in the presence of the type delaration y=x*2.0 is interpreted 
as

temp=x*2.0

y=Int(temp)

temp

is that right?

Reply via email to