posted 12 years ago
It's related to scope, yes. What would be the point of allowing the first version? Without brackets, the if statement just refers to the "block" up to the next semi-colon. Which means that you're declaring a variable which has the scope of this line only - which means it's useless as it can't be used anywhere. That must be a mistake, so the compiler prevents you from doing it.