Skip to content

Commit

Permalink
Merge pull request lampepfl#75 from vreyespue/patch-1
Browse files Browse the repository at this point in the history
Add in CheatSheet how to convert Range to List
  • Loading branch information
julienrf authored Nov 1, 2022
2 parents fe71cf6 + 5cc83b8 commit 77d93d0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions CheatSheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,12 @@ NOTE: For the correct code convention of using postfix or not, read [this](https

val r: Range = 1 until 5 // 1, 2, 3, 4
val s: Range = 1 to 5 // 1, 2, 3, 4, 5
1 to 10 by 3 // 1, 4, 7, 10
6 to 1 by -2 // 6, 4, 2
1 to 10 by 3 // 1, 4, 7, 10
6 to 1 by -2 // 6, 4, 2

val s = (1 to 6).toSet
val xs = (1 to 10).toList // convert range to list

val s = (1 to 6).toSet // convert range to set
s.map(_ + 2) // adds 2 to each element of the set

val s = "Hello World"
Expand Down

0 comments on commit 77d93d0

Please sign in to comment.