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
I like mmyers suggestion of CopyAndAdd. In keeping with a "mutation" theme, maybe you could go with Bud (asexual reproduction), Grow, Replicate, or Evolve? =)
EDIT: To continue with my genetic theme, how about Procreate, implying that a new object is made which is based on the previous one, but with something new added.
A few random thoughts:
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);
Join
seems appropriate.
Apparently I'm the first Obj-C/Cocoa person to answer this question.
NNString *empty = [[NSString alloc] init];
NSString *list1 = [empty stringByAppendingString:@"Hello"];
NSString *list2 = [list1 stringByAppendingString:@"immutable"];
NSString *list3 = [list2 stringByAppendingString:@"word"];
Not going to win any code golf games with this.
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.