That should work.  This works for me:

julia> function f(x)
       y::Float64 = 4.5
       y = x + 5 + y
       return y
       end
f (generic function with 1 method)

julia> f(5)
14.5

However, there are some subtleties, have a look at the manual
http://docs.julialang.org/en/latest/manual/types/

(The preferred style, I think, is not leave no space between a function
name and (...).)

On Tue, 2014-06-03 at 08:48, [email protected] wrote:
> I'm new to Julia, and it is looking very promising. I like how you can 
> specify the type of a function argument by using ::TypeName after the name, 
> so for example:
>
> myfunc (x::Float64)
>
> As this make the variable name more prominent when looking at the code 
> since it comes first. I naturally went to use this syntax elsewhere in the 
> body of a function:
>
> x::Float64 = 2.3
>
> but it doesn't work, and I had to use
>
> x = float64 (2.3)
>
> is there a reason not to support the function argument way of specifying 
> the type of a variable?


Reply via email to