std.array string.split("") bug

Andre Artus andre.artus at gmail.com
Thu Aug 8 03:28:14 PDT 2013


On Wednesday, 7 August 2013 at 19:10:11 UTC, Borislav Kosharov 
wrote:
> Something strange happens when I do this:
>
> unittest {
>     import std.array, std.string;
>     string s = "test";
>     //assert(s.toUpper.split("").join("-") == "T-E-S-T");
>     //"Memory allocation failed"
>     //[Finished in 26.5s]
>     //CPU: 1% -> 50% | 2.7GHz dual core
>     //RAM: 1.6GB -> 2.6GB | 1GB diff
>     assert(s.split("") == ["t","e","s","t"]);
>     //ditto
> }
>
> I just want to achieve what the commented assert's result 
> should be. Is there a better way to do that? And if it is 
> really a bug where should I report it?

There is probably a better way to do it, but I'm still mostly 
ignorant about D.

auto test = "test".map!(a=>to!(string)(a)).join("-");

I would like to be able to write `"test".join('-')` to get the 
same result, after all one wants to intercalate a [repetition of] 
char into an array of chars, but that does not currently work.


More information about the Digitalmars-d mailing list