Can you declare/initialize a bool with an if statement?

Instead of writing:

1
2
3
4
5
6
7
bool test;
if (test!=true){
    //actions;
}
else{
    //more actions'
}


Is there anyway to write it in a little more complex but more effective way something like this (although this doesn't work) it shows what I am trying to do at least.

1
2
3
4
5
6
7
8
bool test(){
   if (some other variable = 5 / true / false etc){
       return true;
   }
   else{
       return false;
   }
}


Or must I initialize the bool every single time first?
Last edited on
Neither of those examples make much sense, especially the second one.
Maybe it's just cause I'm a silly goose, but we could help more if you had a specific example in which you would need to implement whatever it is you're looking for.
Yeh dont worry was just over thinking some ideas, have it fixed.
Topic archived. No new replies allowed.