array concatenation issue, more details

Tobias Kieslich tobias at justdreams.de
Tue Mar 18 11:55:27 PDT 2008


hi,

	after some more thinking i figured I'm way to preoccupied with my
scipting language past. I am concatenating apples and oranges here, it
seems. So let's go again:

	int [2][] y = [[1,2],[3,4]];
	writefln("%s --- length: %d", y, y.length );
	//y = y ~ [[9,10]]; // fail because concatenate [2u][] with [][1u]
	//y = y ~ [9,10]; // success, but wrong result
	//y = y ~ cast (int [2]) [9,10]; // success, but wrong result
	y = y ~ cast (int [2][]) [[9,10]]; // success, right result

so a very properly casted array can be concatenated, however, I think
that this line should produce a proper result as well:
	y = y ~ cast (int [2]) [9,10]; // success, but wrong result

especially because the following fails as well:
	int [2][] y = [[1,2],[3,4]];
	int [2] yx = [40,50];
	y = y ~ yx; // success, but wrong result
	writefln("%s --- length: %d", y, y.length );
	// [[1 2] [3 4] [40 50] [-1075618328 134587053]] --- length: 4

	-Tobias



More information about the Digitalmars-d mailing list