D - question: evaluations
- Lewis <dethbomb hotmail.com> Jan 14 2004
- J Anderson <REMOVEanderson badmama.com.au> Jan 14 2004
- Lewis <dethbomb hotmail.com> Jan 14 2004
in vb anything that isnt 0 evaluates to true, is this the same in d?
//example
char[] foo;
foo.length = 1;
if (foo.length) {
}
//or
uint x;
x = -1;
if (x) { }
//or
while (x) { }
thanks
Jan 14 2004
Lewis wrote:in vb anything that isnt 0 evaluates to true, is this the same in d? //example char[] foo; foo.length = 1; if (foo.length) { } //or uint x; x = -1; if (x) { } //or while (x) { } thanks
Yes, it's the same in C and C++ as well. One difference is that the literal true = 1 in these languages. In VB the literal true = -1; It's particularly useful for pointers, which are null (0) if they don't have anything in them. int* p; if (p) { //There's something in p }
Jan 14 2004
J Anderson wrote:Lewis wrote:in vb anything that isnt 0 evaluates to true, is this the same in d? //example char[] foo; foo.length = 1; if (foo.length) { } //or uint x; x = -1; if (x) { } //or while (x) { } thanks
Yes, it's the same in C and C++ as well. One difference is that the literal true = 1 in these languages. In VB the literal true = -1; It's particularly useful for pointers, which are null (0) if they don't have anything in them. int* p; if (p) { //There's something in p }
neato! thanks Mr. Anderson
Jan 14 2004








Lewis <dethbomb hotmail.com>