Is HE testing "for" or "switch" ?



  • for (int t = 0; t < 4; t++)
    {
    switch (t)
    {
    case 0:
    title = cb.getR1Type();
    value = qb.getR1();
    break;
    case 1:
    title = cb.getR2Type();
    value = qb.getR2();
    break;
    case 2:
    title = cb.getR3Type();
    value = qb.getR3();
    break;
    case 3:
    title = cb.getR4Type();
    value = qb.getR4();
    break;
    default:
    throw new Exception("Program Error in switch: sendEmail");
    }
    if (title.trim().length() > 0)
    {
    j.append('\t');
    j.append(title);
    j.append(":\t");
    j.append(value);
    j.append('\n');
    }
    }



  • Sorry, the message was truncated while posting, please disregard.



  • Re: Is HE testing "for" or "switch" ? - finally

    for (int t = 0; t < 4; t++) {
                    switch (t) {
                        case 0:
                            title = cb.getR1Type();
                            value = qb.getR1();
                            break;
                        case 1:
                            title = cb.getR2Type();
                            value = qb.getR2();
                            break;
                        case 2:
                            title = cb.getR3Type();
                            value = qb.getR3();
                            break;
                        case 3:
                            title = cb.getR4Type();
                            value = qb.getR4();
                            break;
                        default:
                            throw new Exception("Program Error in switch: sendEmail");
                    }    
                    if (title.trim().length() > 0)
                    {    
                        j.append('\t');
                        j.append(title);
                        j.append(":\t");
                        j.append(value);
                        j.append('\n');
                    }
                }



  •   Maybe the developer in question was getting payed by the number of lines of code he wrote :) and come to think of it he  found quite an ingenious solution for writing this piece of code which actually could have been done in a few lines :)).

    The "Specialists Hall of Fame" deserves one more entry next to the Quadrasort developer :))


    Have fun!



  • The FOR-CASE paradigm never ceases to amaze.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.