digitalmars.D.learn - confused about appending arrays...
- clayasaurus (8/16) Jun 05 2005 Ok. So in the next update, whenever you use
- Derek Parnell (18/46) Jun 05 2005 I think that Walter was hinting that the concatenate operator will be
In a post a while back ... Walter wrote:"Trevor Parscal" <trevorparscal hotmail.com> wrote in message news:d7hq0e$1qgp$1 digitaldaemon.com...Ok. So in the next update, whenever you use char[] array = "some"; array ~ "thing"; writefln(array); <-- will print "something"? I thought you used ~= if you want to add append, and ~ if you just want it to return the appened value. I'm thoroughly confused.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.
Jun 05 2005
On Sun, 05 Jun 2005 20:27:49 -0400, clayasaurus wrote:In a post a while back ... 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. > Ok. So in the next update, whenever you use char[] array = "some"; array ~ "thing"; writefln(array); <-- will print "something"? I thought you used ~= if you want to add append, and ~ if you just want it to return the appened value. I'm thoroughly confused.I think that Walter was hinting that the concatenate operator will be working on the right hand side of an expression if one (or both?) of the types are the element types. for eaxample: char[] a; char[] b; char c; a = b ~ c; if ( (c ~ a) == testval) . . . Currently, you get the message "array cat with element not implemented" when you try these sort of things. I expect that the next release will implement this obvious usage. -- Derek Melbourne, Australia 6/06/2005 11:53:49 AM
Jun 05 2005