How are Scala collections able to return the correct collection type from a map operation?

后端 未结 2 1322
谎友^
谎友^ 2020-12-02 04:26

Note: This is an FAQ, asked specifically so I can answer it myself, as this issue seems to come up fairly often and I want to put it in a location where it can (hopefull

2条回答
  •  隐瞒了意图╮
    2020-12-02 05:13

    The Architecture of Scala Collections online pages have a detailed explanation geared towards the practical aspects of creating new collections based on the 2.8 collection design.

    Quote:

    "What needs to be done if you want to integrate a new collection class, so that it can profit from all predefined operations at the right types? On the next few pages you'll be walked through two examples that do this."

    It uses as example a collection for encoding RNA sequences and one for Patricia trie. Look for the Dealing with map and friends section for the explanation of what to do to return the appropriate collection type.

提交回复
热议问题