Difference between revisions of "Type Coercion"
Jump to navigation
Jump to search
Line 7: | Line 7: | ||
`(null)` is okay though. | `(null)` is okay though. | ||
− | `3 * null == | + | `3 * null == 0` |
− | Multiplying by null yields | + | Multiplying by null yields 0. |
`3 / null == Infinity` | `3 / null == Infinity` | ||
Line 22: | Line 22: | ||
Dividing a string by a number will divide the length, then take a substring. | Dividing a string by a number will divide the length, then take a substring. | ||
− | `1/0 = "INF" | "Infinity"` | + | `1/0 == "INF" | "Infinity"` |
The concept of infinity and negative infinity sort of exists, but isn't well-defined. | The concept of infinity and negative infinity sort of exists, but isn't well-defined. |
Revision as of 16:11, 20 February 2024
WIP
Known type coercion rules:
`null * 3 == #@!$` Any statement that begins with `null` is a compiler error, but this may change in the future. `(null)` is okay though.
`3 * null == 0` Multiplying by null yields 0.
`3 / null == Infinity` In division, null acts a lot like `0`.
`3 + "3" == "33"` If an expression contains a string, the entire expression will be coerced into a string.
`"3" * 5 == "33333` Multiplying a string by a number will replicate the string.
`"1234" / 2 == "12"` Dividing a string by a number will divide the length, then take a substring.
`1/0 == "INF" | "Infinity"` The concept of infinity and negative infinity sort of exists, but isn't well-defined.