Thread overview
Appending Arrays
May 31, 2005
Trevor Parscal
May 31, 2005
John C
Jun 01, 2005
Walter
Jun 01, 2005
Trevor Parscal
May 31, 2005
I know that the ~ is the greatest things since sliced arrays [ .. ] :)

But when it comes to appending an array with a new element, I am feeling like I must be missing something..

Example:

char[] word = "test";
char letter = '1';

// Wont work?
word ~ letter;

// Works fine...
word.length = word.length + 1;
word[word.length - 1] = letter;

Why is this so complex to do? Is there a way I didn't learn from the D language docs?

-- 
Thanks,
Trevor Parscal
www.trevorparscal.com
trevorparscal@hotmail.com
May 31, 2005
"Trevor Parscal" <trevorparscal@hotmail.com> wrote in message news:d7hq0e$1qgp$1@digitaldaemon.com...
>I know that the ~ is the greatest things since sliced arrays [ .. ] :)
>
> But when it comes to appending an array with a new element, I am feeling like I must be missing something..
>
> Example:
>
> char[] word = "test";
> char letter = '1';
>
> // Wont work?
> word ~ letter;

Try

    word ~= letter;

>
> // Works fine...
> word.length = word.length + 1;
> word[word.length - 1] = letter;
>
> Why is this so complex to do? Is there a way I didn't learn from the D language docs?
>
> -- 
> Thanks,
> Trevor Parscal
> www.trevorparscal.com
> trevorparscal@hotmail.com


June 01, 2005
"Trevor Parscal" <trevorparscal@hotmail.com> wrote in message news:d7hq0e$1qgp$1@digitaldaemon.com...
> char[] word = "test";
> char letter = '1';
>
> // Wont work?
> word ~ letter;

Right, but that's a compiler bug. It'll be fixed in the next update.


June 01, 2005
Walter wrote:
> "Trevor Parscal" <trevorparscal@hotmail.com> wrote in message
> news:d7hq0e$1qgp$1@digitaldaemon.com...
> 
>>char[] word = "test";
>>char letter = '1';
>>
>>// Wont work?
>>word ~ letter;
> 
> 
> Right, but that's a compiler bug. It'll be fixed in the next update.
> 
> 
Thank you, thank you, thank you, thank you....

Just what i always dreamed of, just one update away..

Walter = the man!

-- 
Thanks,
Trevor Parscal
www.trevorparscal.com
trevorparscal@hotmail.com