Difference between concatenation and appendation
Laeeth Isharc via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Jan 25 17:53:23 PST 2015
On Monday, 26 January 2015 at 01:17:17 UTC, WhatMeWorry wrote:
> Ok, I just made up that word. But what is the difference
> between appending and concatenating? Page 100 of TPDL says
> "The result of the concatenation is a new array..." and the
> section on appending talks about possibly needing expansion and
> reallocation of memory.
>
> But I still don't feel like I have a grasp on the subtleties
> between them. Can someone give a short and sweet "rule of
> thumb"?
>
> It might be so obvious that I'll regret posting this.
>
> Thanks.
At the risk of the blind leading the blind (I am no expert), I
think concatenation and append are used as synonyms (the same
meaning is meant). a~=b or a=a~b
If there isn't enough space then the whole array is reallocated.
You can see this/change this property by reading capacity or
calling reserve.
If you want to do lots of appends / concatenates then use
appender in std.array which is faster and more efficient.
More information about the Digitalmars-d-learn
mailing list