|
|
|
|
|
by StefanKarpinski
2336 days ago
|
|
Mostly spot on, although it's very rare for local variables to require type annotation—type inference can easily figure it out for locals. Unless, of course, they are assigned from an untyped external source the compiler couldn't possibly know. You could, for example read something from a JSON source knowing that it should be an number, annotate it with `json["field"]::Float64` and then the compiler will emit code to check the type and throw an error unless the type is actually a Float64. |
|
So, if not on local variables, where are explicit types necessary (other than function parameters)?