[Swift-devel] Join function?
David Kelly
davidk at ci.uchicago.edu
Tue Apr 3 13:02:24 CDT 2012
Hello,
Is there a way to concatenate all elements of an array into a single string? I would also like to define a separator between elements. I was thinking of something similar to Perl's join function.
If I have:
string a[];
a[0] = "this";
a[1] = "is";
a[2] = "a";
a[3] = "test";
How can I get it into "this is a test" or "this:is:a:test"? @strcat returns a reference. I can tracef with %q and get "[this,is,a,test]", but it doesn't give me any control over the formatting as far as I know.
I could call a shell script to do this, just wondering if there was another way.
David
More information about the Swift-devel
mailing list