int.parse() / toString()
Text ↔ number conversion.
Syntax
int.parse(text) // number.toString()
Description
int.parse converts text to an integer, double.parse converts to a decimal. toString converts a number to text. Text that cannot be converted causes an error.
Example
Loading editor…
Expected output
30 42!
When to use?
Accounting for text coming from users/files.
Common mistakes
- ⚠️ int.parse("abc") causes an error; only text representing numbers can be converted.