Navigation
Synopsis Convert a string value to integer.
Function
  1. int toInt(str s) throws IllegalArgument
  2. int toInt(str s, int r) throws IllegalArgument
Usage import String;
Description
  1. Converts string s to integer.
  2. Convert string s to integer using radix r.
Throws IllegalArgument when s cannot be converted.
Examples
rascal>import String;
ok
rascal>toInt("11");
int: 11
rascal>toInt("11", 8);
int: 9
Now try an erroneous argument:
rascal>toInt("abc");
|rascal://String|(9689,431,<414,0>,<434,52>): IllegalArgument()
	at *** somewhere ***(|rascal://String|(9689,431,<414,0>,<434,52>))
	at toInt(|stdin:///|(6,5,<1,6>,<1,11>))


Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.