char[][] join ==> string

Ali Çehreli acehreli at yahoo.com
Thu Apr 7 11:25:17 PDT 2011


On 04/07/2011 01:04 AM, spir wrote:
 > On 04/07/2011 09:52 AM, spir wrote:
 >> On 04/07/2011 03:07 AM, Ali Çehreli wrote:
 >>>> Given an array of strings std.string.join() returns a single string:
 >>>>
 >>>> import std.string;
 >>>> void main() {
 >>>> string[] a1 = ["hello", "red"];
 >>>> string j1 = join(a1, " "); // OK
 >>>> }
 >>>>
 >>>>
 >>>> But in a program I need an array of mutable arrays of chars. If I
 >>>> join the
 >>> arrays I get a mutable array of chars.
 >>> [...]
 >>> Finally, casting ourselves works:
 >>>
 >>> string j2 = cast(string)join(a2, " ");

 > Questions: did you know this idiom? if yes, have you found it yourself
 > or read about it? if the latter, where?

I had heard about assumeUnique() a couple of times in these forums. I 
remember looking at its implementation.

Ali



More information about the Digitalmars-d-learn mailing list