News for hackers. Stuff that matters.
Re:Use labels to break ifs in JavaScript by VMG on Wednesday August 07, 2013 @08:05AM (#6172199)
The best I can come up with is this:

    ANIMAL: if (isAnimal) {
        DOG: if (isDog) {
            POODLE: if (isPoodle) {
                if (color == green) {
                    break POODLE; // we don't want green poodles
                }

                if (age > 10) {
                    break DOG; // we don't want old dogs
                }

                if (weight > 20) {
                    break ANIMAL; // we don't want heavy animals
                }

                // more poodle conditions
            }

            // more dog conditions
        }

        // more animal conditions
    }

There are no comments on this comment yet.