You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var::T = val can be used to declare the type of a local variable, and it is enforced, but this is not true for global var::T = val.
For example, the following enforces the type:
julia> function foo(x)
local y::Bool = x
end
foo (generic function with 1 method)
julia> foo("hello")
ERROR: `convert` has no method matching convert(::Type{Bool}, ::ASCIIString)
in foo at none:2
But this does not:
julia> y = false
false
julia> function foo(x)
global y::Bool = x
end
foo (generic function with 1 method)
julia> foo("hello")
"hello"
julia> y
"hello"
The text was updated successfully, but these errors were encountered:
var::T = val
can be used to declare the type of a local variable, and it is enforced, but this is not true forglobal var::T = val
.For example, the following enforces the type:
But this does not:
The text was updated successfully, but these errors were encountered: