-
Notifications
You must be signed in to change notification settings - Fork 1
Type interpretation
JordanL2 edited this page May 25, 2020
·
3 revisions
An operation usually require a certain type for each input, but it will try to interpret an input as the type it requires. For example, if the string '123' is provided for a numerical input, it will be interpreted as the number 123. This works for numbers in any format, for example the string '0b10101' will be interpreted as the binary number 10101. On the other hand if a string input is required, the number 123 will be interpreted as the string '123'.
| Required | Provided | Result |
|---|---|---|
| Number | Boolean | True treated as a 1, False treated as a 0 |
| Number | String | Interpreted as number if it matches the syntax of a number type |
| Boolean | Number | Rejected |
| Boolean | String | Rejected |
| String | Number | Interpreted as a string, e.g. 123 becomes '123' |
| String | Boolean | Interpreted as the string 'True' or 'False' |
| Date | Number | Rejected |
| Date | Boolean | Rejected |
| Date | String | Interpreted as a date if the syntax is correct |