1. 程式人生 > >kotlin函式區間

kotlin函式區間

package kotlinall.chapter1
//kotlin 區間
val range:IntRange = 0..1024//[0,1024]
val range_integer:IntRange = 0 until 1024//[0,1024)

val emptyRange:IntRange = 0..-1
fun main(args:Array<String>){
    println(emptyRange.isEmpty())
    println(range.contains(400))
    println(50 in range)//等價與 range.contains

    for(i in range){
        println("${i}")
    }
}