How to create List from Range
To turn any sequence s
into a list, use s.toList
I'm sure digitalross' is more efficient in this case, though.
There's an apply
method on the List
companion object which takes a range and returns a List
:
scala> List.range(2, 11)
res0: List[Int] = List(2, 3, 4, 5, 6, 7, 8, 9, 10)
There are lots of useful List
factory methods in the List
collection documentation.