Scala的to和until

object test03 {
  def main(args: Array[String]): Unit = {
    //to  每次迭代爲1
    val to1=1 to 10
    print("to1"+to1)
    println()

    //to by 自定義迭代的大小
    val to2=1 to 10 by 2
    print("to2"+to2)
    println()
    //Range:until  (包前不包後,每次迭代爲1)
    val until1=1 until 10
    print("until1"+until1)
    println()
    //Range:until  by (自定義迭代)
    val until2=1 until 10 by 2
    print("until2"+until2)
  }
}
相關文章
相關標籤/搜索