I do not see where kotlin-stdlib/kotlin/String/get indicates whether it is 0 or 1 based, target or implementation defined. Where is this documented?
Asked
Active
Viewed 1,124 times
-1
-
3get() on a String is 0 indexed as this answer shows: https://stackoverflow.com/a/50298227/7902532 – cheemcheem Jul 30 '19 at 21:43
-
Possible duplicate of [How can i access a char in string in at specific number?](https://stackoverflow.com/questions/50297288/how-can-i-access-a-char-in-string-in-at-specific-number) – Aivean Jul 31 '19 at 05:00
-
It's zero-based like any other collection/array structure – Nikolai Shevchenko Jul 31 '19 at 06:30
1 Answers
1
It is 0-based.
For example:
val str = "Hello Kotlin Strings"
println(str.get(4)) //prints o

Collin Barrett
- 2,441
- 5
- 32
- 53

Ck Douglas
- 11
- 4