Array literals

Michel Fortin michel.fortin at michelf.com
Sat Oct 18 11:06:14 PDT 2008


On 2008-10-18 11:31:09 -0400, KennyTM~ <kennytm at gmail.com> said:

>>> // The only change from the code above is
>>> // swapping the order of "Hello" and "what"
>>> import std.stdio: writefln;
>>> void main() {
>>>     char[static][static] a = ["what", "Hello"];
>>>     writefln(a[1].length); // 5
>>> }
>>> 
>>> [...]
>> For that to work, you'd also need implcit conversion from T[4] to T[5]. 
>> How are your proposing to do that?
> 
> Pad with T.init

Should I take it then that the following assertions should hold true?

	char[static][static] a = ["what", "Hello"];
	assert(a[0] == "what\0");
	assert(a[0] != "what");

That seems completly backward.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d mailing list