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

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

    In situations like that, I usually go with Concat. That usually implies to me that a new object is being created.

    var p = listA.Concat(listB);
    var k = listA.Concat(item);
    

提交回复
热议问题