Please see
http://docs.julialang.org/en/release-0.4/manual/types/#type-declarations

Currently, type declarations cannot be used in global scope, e.g. in the
> REPL, since Julia does not yet have constant-type globals. Note that in a
> function return statement, the first two of the above expressions compute a
> value and then :: is a type assertion and not a declaration.


On Sat, Nov 7, 2015 at 2:26 AM, Pranit Bauva <[email protected]> wrote:

> hey everyone!
>
> I tried defining variables of particular Type in this script. They don't
> work in the "normal mode" but they run in functions properly. To explain
> the problem, here is a code snippet from a file "type_test.jl" which I
> invoked by typing "julia type_test.jl" in the terminal.
>
> function foo()
>     a::Int8 = 10
>     b::Int8 = 20
>     a + b
> end
>
> foo()
> x::Int8 = 10
> y::Int8 = 20
> x + y
>
> There shows an error that x is not defined. Can please someone explain
> this kind of behavior ?
>
> Regards,
> Pranit Bauva
>

Reply via email to