Open tpfau opened 2 years ago
I think the sentence
You can force the type using the :: syntax (read is instance of.)
is quite incorrect in that context. The ::
operator, when used after an expression, is used to hint what the expected type is and throw an error if the returned type does not match the expected type.
For the example
a = 1
b = 3
(a/b)::Int
The /
operator always returns a float when called with integer parameters (otherwise you would have type instability) and hence you get an error since a float cannot be an integer
see the julia documentation: https://docs.julialang.org/en/v1/manual/types/#Type-Declarations
Is it better now, @lucaferranti?
In the last section (Advanced: Dynamic types) if you run the code you get an exception. IS that intentional and for the students to figure out, or should this be corrected?