Typechecking - Coercion
Coercion: Can I change the value from one type to another? (Use the implicit coercison table.)
From \ To |
int |
double |
string |
int |
--- |
Yes |
Yes |
double |
No |
--- |
Yes |
string |
No |
No |
--- |
Recall that, if we define:
int foo(double x, string y) { ... }
We describe it as:
foo: double -> string -> int // return type goes last
When we call, we pass arguments:
foo(3.14, "hi")