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

前端 未结 30 1294
夕颜
夕颜 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:30

    I think that Plus() and Minus() or, alternatively, Including(), Excluding() are reasonable at implying immutable behavior.

    However, no naming choice will ever make it perfectly clear to everyone, so I personally believe that a good xml doc comment would go a very long way here. VS throws these right in your face when you write code in the IDE - they're hard to ignore.

提交回复
热议问题