Copyright © 2024 SingChun Lee Bucknell University. All rights reserved. Sites developed using revealjs.
From \ To | int | double | string |
---|---|---|---|
int | --- | Yes | Yes |
double | No | --- | Yes |
string | No | No | --- |
+: int -> int -> int
+: double -> double -> double
+: string -> string -> string
-: int -> int -> int
-: double -> double -> double
Note: we describe a function using arrows with the last one as the return type.
Checking: What function is that? Find all functions with that name, put them in order by type, try them one by one.
Examples of the order of operations in Java-light:
Expression | Correct | Wrong | Remark |
---|---|---|---|
a + b + c | (a + b) + c | a + (b + c) | Associativity from left to right |
a + b * c | a + (b * c) | (a + b) * c | Precedence of * higher than + |
a * b / c | (a * b) / c | a * (b / c) |