The more interesting question
H. S. Teoh
hsteoh at quickfur.ath.cx
Wed May 16 10:24:38 PDT 2012
On Wed, May 16, 2012 at 09:17:17PM +0400, Gor Gyolchanyan wrote:
> On Wed, May 16, 2012 at 9:07 PM, Steven Schveighoffer
> <schveiguy at yahoo.com>wrote:
>
> > On Wed, 16 May 2012 12:21:27 -0400, Gor Gyolchanyan <
> > gor.f.gyolchanyan at gmail.com> wrote:
> >
> >
> >> if("" != []) assert("".length != 0);
> >>
> >> Will this fail?
> >>
> >
> > No. Ambiguities only come into play when you use 'is'. I highly
> > recommend not using 'is' for arrays unless you really have a good
> > reason, since two slices can be 'equal' but 'point at different
> > instances'.
[...]
> Doesn't assert("".length != 0) look extremely counter-intuitive?
[...]
Code:
import std.stdio;
void main() {
writeln("" == []);
writeln("" != []);
writeln("".length);
}
Output:
true
false
0
Where's the problem?
T
--
Recently, our IT department hired a bug-fix engineer. He used to work for Volkswagen.
More information about the Digitalmars-d
mailing list