【发布时间】:2019-07-03 23:07:46
【问题描述】:
(1 to 4).to[scala.collection.immutable.Set] 和 (1 to 4).toSet 之间的 Scala 区别?
scala> (1 to 4).toSet
res37: scala.collection.immutable.Set[Int] = Set(1, 2, 3, 4)
scala> (1 to 4).to[scala.collection.immutable.Set]
res38: scala.collection.immutable.Set[Int] = Set(1, 2, 3, 4)
scala> (1 to 4).to[Set]
res39: Set[Int] = Set(1, 2, 3, 4)
scala> Set(1 to 4:_*)
res14: scala.collection.immutable.Set[Int] = Set(1, 2, 3, 4)
【问题讨论】:
标签: scala collections