Thread: !my_bool vs bool=false

  1. #1
    Registered User QuestionKing's Avatar
    Join Date
    Jan 2009
    Posts
    68

    !my_bool vs bool=false

    I was under the impression that
    Code:
     !my_bool;
    would change my_bool from true to false or false to true... does it not work this way?
    Asking a question you already know the answer to might teach you something you did not know...

  2. #2
    Ex scientia vera
    Join Date
    Sep 2007
    Posts
    477
    Quote Originally Posted by QuestionKing View Post
    I was under the impression that
    Code:
     !my_bool;
    would change my_bool from true to false or false to true... does it not work this way?
    Code:
    !aBool;
    Does nothing.

    Code:
    bool foo = true;
    
    foo = !foo; // foo is false
    foo = !foo; // foo is true
    "What's up, Doc?"
    "'Up' is a relative concept. It has no intrinsic value."

  3. #3
    Registered User QuestionKing's Avatar
    Join Date
    Jan 2009
    Posts
    68
    I guess I should have included more code:
    Code:
    bool my_bool = true;
    do
      {
         //... if, else if,...
         else
         {
             my_bool = !my_bool;
         }
      }while(my_bool);
    ...but it appears I had a different problem, which I found. tyvm for the reply
    Asking a question you already know the answer to might teach you something you did not know...

Popular pages Recent additions subscribe to a feed