What's the best name for a non-mutating “add” method on an immutable collection?

前端 未结 30 1284
夕颜
夕颜 2020-11-29 16:47

Sorry for the waffly title - if I could come up with a concise title, I wouldn\'t have to ask the question.

Suppose I have an immutable list type. It has an operat

30条回答
  •  半阙折子戏
    2020-11-29 17:27

    Whenever I'm in a jam with nomenclature, I hit up the interwebs.

    thesaurus.com returns this for "add":

    Definition: adjoin, increase; make further comment

    Synonyms: affix, annex, ante, append, augment, beef up, boost, build up, charge up, continue, cue in, figure in, flesh out, heat up, hike, hike up, hitch on, hook on, hook up with, include, jack up, jazz up, join together, pad, parlay, piggyback, plug into, pour it on, reply, run up, say further, slap on, snowball, soup up, speed up, spike, step up, supplement, sweeten, tack on, tag

    I like the sound of Adjoin, or more simply Join. That is what you're doing, right? The method could also apply to joining other ImmutableList<>'s.

提交回复
热议问题