FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

compare with 0

 
Post new topic   Reply to topic     Forum Index -> General
View previous topic :: View next topic  
Author Message
nik



Joined: 28 Feb 2007
Posts: 4

PostPosted: Thu Mar 01, 2007 7:57 am    Post subject: compare with 0 Reply with quote

today when testing D i found out, that i can't compare a reference with 0, i always get a segmentation fault. Please look at this code:

Code:

import std.stdio;

class Test2
{
   int a, b;
}

class Test
{
   Test2 test = null;

   void foo( )
   {
      if( test == null ) writefln( "adfsfd" );
   }
}

void main( char[][] args )
{
        Test test = new Test();
        test.foo();
}
Back to top
View user's profile Send private message
nik



Joined: 28 Feb 2007
Posts: 4

PostPosted: Thu Mar 01, 2007 8:02 am    Post subject: Reply with quote

now i found the answer, you have to use the is-operator
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> General All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group