Difference between Iterator and Stream in Scala?

前端 未结 2 1935
清酒与你
清酒与你 2020-12-01 02:56

It seems that both Iterator and Stream are lazy and allow you to keep returning elements to your heart\'s content. What\'s the difference between the two?

2条回答
  •  广开言路
    2020-12-01 03:14

    Stream memoises and Iterator does not. You can traverse the same Stream multiple times and get the same result each time. Iterator, on the other hand, can only be traversed once.

提交回复
热议问题