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

02_Julia notebook #14

Open
tpfau opened this issue Sep 10, 2021 · 3 comments
Open

02_Julia notebook #14

tpfau opened this issue Sep 10, 2021 · 3 comments

Comments

@tpfau
Copy link
Member

tpfau commented Sep 10, 2021

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?

@lucaferranti
Copy link

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

@lucaferranti
Copy link

see the julia documentation: https://docs.julialang.org/en/v1/manual/types/#Type-Declarations

@rantahar
Copy link

Is it better now, @lucaferranti?

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

3 participants