Member Avatar for Geek-Master

I've used "if and else" statements to test for conditions, but if's can get very "iffy" sometimes. Specially when you need to test for several possibilites.

I was wondering if there is another way to do tests for conditions instead of using the IF. Just for better programming.

example: tic-tac-toe
testing to see if X is three in a row or
O is three in a row.

If anyone knows of a better way to "test" instead of using IF ELSE stuff, I would be happy to hear from ya.

It would probably be easier if you posted a real example of an if tree that you don't like.

Dave's right we need more context. It sounds like you might be looking for the switch statement.

switch(expression)
{
case constant-expression : statements; break;
.
.
[I]n[/I]
default : statements;

}
Member Avatar for Geek-Master

I'm just looking for other methods to test input or conditions.

hollystyles, you say that I can look at "switch statements". Then I will do some research on them. Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.