Monday, 21 September 2020

Scala: to method


scala> for (data <- 1.to(10)){
     |  println(data)
     | }
1
2
3
4
5
6
7
8
9
10

Instead of 1.to(10), you can use ‘1 to 10’.

scala> for (data <- 1 to 10){
     |  println(data)
     | }
1
2
3
4
5
6
7
8
9
10
  

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment