xxxInPlace or xxxCopy?

Trass3r un at known.com
Thu Jan 20 03:44:47 PST 2011


> If you have replace(str, "hello", "world");
> you don't know whether it's changed the value in place or if you're
throwing away a return value. However, if you have
> auto newStr = replace(str, "hello", "world");
> replaceInPlace(newStr, "world", "hello");
> it's quite clear that the first one returns a value and the the
second one does it in place.

Very true. Imho function names would also be more understandable this
way cause xInPlace is unambiguous while xCopy might lead to confusion
(at least I could imagine a stranger misinterpreting replaceCopy etc.)


More information about the Digitalmars-d mailing list