leeappdalecom wrote:Cheers guys.
Another one.
Does anyone write one line conditional statements without curly braces?
e.g.
if (1 == 1)
doSomething;
as opposed to:
if (1 == 1)
{
doSomething;
}
I always use the latter but it seems everyone here uses the first method even for 'for' and 'foreach' loops.
I just find it very messy and unreadable.
I always (or almost always) put braces around one line conditional statements (or more to the point, single statement conditions) for two reasons:
1) It's clearer.
2) Just because there's only one statement today, doesn't mean there'll only be one tomorrow. Any reformatting that doesn't need to be done is a potential error avoided.