October 2018
Intermediate to advanced
370 pages
9h 15m
English
Kotlin provides three different types of ranges: integer, long, and character. Each range can be declared with explicit type declaration:
val myIntRange : IntRange = 1..10val myLongRange : LongRange = 1..10Lval myCharRange : CharRange = 'a'..'z'for (ch in myCharRange) { println(ch)}
Like other variables, a range can also be declared without explicitly declaring the variable type:
val IntRange = 1..10val LongRange = 1..10Lval CharRange = 'a'..'z'for (ch in myCharRange) { println(ch)}
While declaring a range of long type, it is necessary to provide the L character with at least one of the elements to differentiate it from the integer type of range.
Read now
Unlock full access