if statement with multiple possible outcomes?

ok so getting straight to the point is it possible to do this?:

if (variable == 1)
{
      //do this shit
      OR
      //do this shit
}

thanks

if (variable == 1)
{
      //do this S***
}
else if (variable == 2)
{
      //do this S***
}
else
{
     //do something else
}

Also, you might want to check out the switch statement.

1 Like

Well, that’s why you have if statements, right? You can nest if statements like this:

if (variable == 1)
{
      if (somethingElse == something)
      {
            //do this S***
      }
      else
      {
            //do this S***
      }
}
1 Like

Nesting isn’t always the best option, but this examples is just to give you a clue - you can make really complex if statements. You may want to share a bit more about what you want to achieve so we can give you a better, easier to understand example

1 Like