OCLOperators strToInt
Created by Peter on 2019-11-22 · Last edited by Sandra.akech on 2026-02-18.
Returns an Integer of value equal to self, or |invalid| if self does not represent an integer.
| Expression | Result |
|---|---|
| '3.0'.strtoint | invalid |
| '4'.strtoint | 4 |
| 'toInteger'.strtoint | invalid |
See also: Parse
| Format | Example | Valid | Result |
|---|---|---|---|
| Positive Integer | '40' | Yes | 40 |
| Negative Integer | '-20' | Yes | -20 |
| Zero | '0' | Yes | 0 |
| With Whitespace | ' 100' | Yes | 100 |
| Decimal | '13.4' | No | 0 |
| Comma Separate | '5,500' | No | 0 |
| Non-Numeric | 'abc' | No | 0 |
| Empty String | '' | No | 0 |
