Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typed variable declaration in REPL #5627

Closed
filmackay opened this issue Jan 31, 2014 · 2 comments
Closed

Typed variable declaration in REPL #5627

filmackay opened this issue Jan 31, 2014 · 2 comments

Comments

@filmackay
Copy link

I noticed that these declarations don't work in REPL (taken from doco):

julia> x::Int8        # a variable by itself
ERROR: x not defined

julia> x::Int8 = 10   # as the left-hand side of an assignment
ERROR: x not defined

How should one declare a variable/value of a given type in REPL?

@ihnorton
Copy link
Member

"In value contexts, such as f(x::Int8), the :: is a type assertion again and not a declaration. Note that these declarations cannot be used in global scope currently, in the REPL, since Julia does not yet have constant-type globals."

http://docs.julialang.org/en/latest/manual/types/#type-declarations

@ihnorton
Copy link
Member

see also #964

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants