2012/2/28 Jesse Phillips <jessekphillip...@gmail.com> > > > string is an array, alias immutable(char)[], so the same rules apply. >
I know about string being an alias, hence the question. This means that I can do if (someString.length) { ... } without worrying about the null case (?). That's great! > There is no NullPointerException, it is a segfault/Access Violation/Bus > Error. > > Ah, that will take some getting used to. =) I guess there's a good reason though (there seems to be good reasoning behind most of the design choises). Off topic, but may I ask what might be the reason? An empty array and a null array are equal. And this definition does work > well. > > You can distinguish between an empty array and a null array by using the > 'is' operator. What is pointed out here is that an empty array literal, [], > is null while an empty array is not. This behavior is easy to explain in > terms sf why, but may not be a good choice for sake of consistency. > Yes, that feels kind of "wrong" to me - that an empty array literal is null while an empty array isn't. It's not intuitive, easily explainable or not. / Mikael