Sunday, October 03, 2004

IF-ELSE statements

Its really cool to see that sometimes simple if-else conditional statements can be so confusing.

Here is a conditional statement:

if( 1 == 1 ) // You can make any condition it does not matter
string myString = "Hello World";

What do you expect will it run or not ? Well it will not run and give you error "Embedded statement cannot be a declaration"

You can write the same statement correctly if you add the paranthesis like this:

if( 1 == 1 )
{
string myString = "Hello World";
}

Do you find it amazing cause I sure do ?

No comments: