Collection type generated by for with yield

前端 未结 2 1267
终归单人心
终归单人心 2020-12-31 01:05

When I evaluate a for in Scala, I get an immutable IndexedSeq (a collection with array-like performance characteristics, such as efficient random a

2条回答
  •  误落风尘
    2020-12-31 01:51

    You can always transform a range to a list using toList:

    > val s = for (i <- (0 to 9).toList) yield math.random + i
    > s  : List[Double]
    

提交回复
热议问题