array setting : Whats going in here?

claptrap clap at trap.com
Sat Oct 7 00:00:48 UTC 2023


char[] foo;
foo.length = 4;
foo[] = 'a'; // ok sets all elements
foo[] = "a"; // range error at runtime?
foo[] = "ab"; // range error at runtime?

So I meant to init with a char literal but accidently used double 
quotes. Should that even compile? Shouldn't the compiler at least 
complain when trying to init with "ab"?


More information about the Digitalmars-d-learn mailing list