循环步长
def main(args: Array[String]): Unit = { println(10 to 1 by -1) //Range(10, 9, 8, 7, 6, 5, 4, 3, 2, 1) }
API——Reverse
def main(args: Array[String]): Unit = { (1 to 10) .reverse.foreach(println) //10 9 8 7 6 5 4 3 2 1 }
def main(args: Array[String]): Unit = { println(10 to 1 by -1) //Range(10, 9, 8, 7, 6, 5, 4, 3, 2, 1) }
def main(args: Array[String]): Unit = { (1 to 10) .reverse.foreach(println) //10 9 8 7 6 5 4 3 2 1 }