If I want to convert Range
to Set
I can write
(0 to 9).toSet
What if I need to convert Range
to SortedSet
? I can write something like:
scala.collection.immutable.SortedSet[Int]((0 to 9): _*) scala.collection.immutable.SortedSet[Int]() ++ (1 to 9)
Does it make sense? Is there any "better" (efficient/simple) way to convert Range
to SortedSet
?
What could possibly be more simple than this? (You don't need the type parameter or the extra parentheses.)
SortedSet(0 to 9:_*)
It should also be reasonably efficient.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With