[Issue 2006] Appending empty array using ~= doesn't work
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Apr 18 12:46:19 PDT 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2006
------- Comment #1 from wbaxter at gmail.com 2008-04-18 14:46 -------
That's funny I was just about to file this one myself a couple of days ago, BUT
then I decided that it probably isn't really a bug.
[] could be an empty array of any type. So the compiler is interpreting it as
an empty string[][], not an empty string[]. You have a T[], you concat an
empty T[], your original array isn't supposed to change.
I will agree it's not the most useful of behaviors, and the doc could certainly
be clearer about what will happen in such a case, but I don't think its
actually a bug. It's just the compiler interpreting [] in a not-so-useful
manner. If you type a literal "~= []" in the code then clearly you want
something to happen.
The workaround is to use "~= [[]]" instead.
--
More information about the Digitalmars-d-bugs
mailing list