scala中to和util操作

  // Range:to:默认步进为1
  val to1 = 1 to 10
  println(to1)
  // 定义一个不进为2的Range
  val to2 = 1 to 10 by 2
  println(to2)
  println(to2.toList)

  // Range:until
  val until1 = 1 until 10
  println(until1)
  val until2 = 1 until 10 by 2
  println(until2)

 

posted @ 2017-12-06 19:23  麻雀虽小五脏俱全  阅读(6617)  评论(1编辑  收藏  举报