Skip to main content
Post Made Community Wiki by user36294
added 262 characters in body
Source Link

I usually use braces, but there are some cases where I don't.

object GetObject() {
    // calculate obj1
    if(objobj1 != null)
        return obj;obj1;

    // calculate obj2
    if(obj2 != null)
        return obj2;

    // calculate obj3
    if(obj3 != null)
        return obj3;

    return defaultObj;
}

To me, it would just be silly to add them there. If someone adds a statement after the return, we have bigger problems than scoping issues.

I usually use braces, but there are some cases where I don't.

if(obj != null)
    return obj;

To me, it would just be silly to add them there. If someone adds a statement after the return, we have bigger problems than scoping issues.

I usually use braces, but there are some cases where I don't.

object GetObject() {
    // calculate obj1
    if(obj1 != null)
        return obj1;

    // calculate obj2
    if(obj2 != null)
        return obj2;

    // calculate obj3
    if(obj3 != null)
        return obj3;

    return defaultObj;
}

To me, it would just be silly to add them there. If someone adds a statement after the return, we have bigger problems than scoping issues.

Source Link

I usually use braces, but there are some cases where I don't.

if(obj != null)
    return obj;

To me, it would just be silly to add them there. If someone adds a statement after the return, we have bigger problems than scoping issues.