【发布时间】:2011-06-15 10:40:27
【问题描述】:
scala> (1 to 10).iterator.map{_ * 2}.toList
res1: List[Int] = List(2, 4, 6, 8, 10, 12, 14, 16, 18, 20)
scala> (1 to 10).view.map{_ * 2}.force
res2: Seq[Int] = Vector(2, 4, 6, 8, 10, 12, 14, 16, 18, 20)
除了使用 next,hasNext,什么时候应该选择 iterator over view 或 view over iterator?
【问题讨论】:
标签: scala collections