Range properties

Range provides two properties that allow us to access the first element of a range:

val myRange = 1..10 
println("first " + myRange.first)
println("start " + myRange.start)

first and last properties are pretty much same, behind the scene start property calls first property.

It also provides two properties that allow us to access the last element of a range:

println("last " + myRange.last)
println("endInclusive " + myRange.endInclusive)

In these examples, the first block of code will return 1 and the second block of code will return 10.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.151.220