Synopsis Retrieve a substring via its index.
Syntax Exp1 [ Exp2 ]
Exp1 Exp2 Exp1 [ Exp2 ]
str int str
Description String subscription uses the integer value of Exp2 as index in the string value of Exp1. The value of Exp2 should be greater or equal 0 and less than the number of characters in the string. If this is not the case, the exception IndexOutOfBounds is thrown.
Examples Introduce a string, assign it to S and retrieve the element with index 1:
rascal>S = "abc";
str: "abc"
str: "b"
Explore an error case:
|stdin:///|(2,1,<1,2>,<1,3>): IndexOutOfBounds(5)
	at ___SCREEN_INSTANCE___(|stdin:///|(0,5,<1,0>,<1,5>))

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