Decreasing for loop in Scala?

前端 未结 8 1043
一生所求
一生所求 2020-12-17 20:24

First day and first attempt at using Scala - so go easy on me! I\'m trying to rewrite some old Java code I have which is simply a function which takes two numbers and prints

8条回答
  •  北荒
    北荒 (楼主)
    2020-12-17 21:08

    A point to add to this answer, if you do something like this

    for(j <- finish to start){......}
    

    sbt does not even show the error. So if you want a decrementing for loop you need to do this

    for(j <- finish to start by -1){.......}
    

提交回复
热议问题