scala.collection.breakOut vs views

后端 未结 4 972
北海茫月
北海茫月 2021-02-19 08:01

This SO answer describes how scala.collection.breakOut can be used to prevent creating wasteful intermediate collections. For example, here we create an intermediat

4条回答
  •  梦如初夏
    2021-02-19 08:40

    You're going to make a trip from England to France.

    With view: you're taking a set of notes in your notebook and boom, once you've called .force() you start making all of them: buy a ticket, board on the plane, ....

    With breakOut: you're departing and boom, you in the Paris looking at the Eiffel tower. You don't remember how exactly you've arrived there, but you did this trip actually, just didn't make any memories.

    Bad analogy, but I hope this give you a taste of what is the difference between them.

提交回复
热议问题