A array bug?

Ellery Newcomer ellery-newcomer at utulsa.edu
Wed Jan 28 08:15:38 PST 2009


taqya wrote:
> Hi,i write this code. then d compiler is shutdown.
> Is it a array bug?
> 
> //Digital Mars D Compiler v2.014 (windows)
> import std.stdio;
> int main()
> {
> 	char[] a = "a".dup;
> 	char[] b = "b".dup;
> 	writefln(a + b); //Error: Array operations not implemented
> 	return 0; 		 
> }

'+' implies you're trying to add "a" and "b" together e.g.
(char)((int) 'a' + (int) 'b')

If so, the error informs you why you can't do that.

If you're trying to concatenate, use the '~' operator.

assert ( "a" ~ "b" == "ab" );


More information about the Digitalmars-d-learn mailing list