logoalt Hacker News

jagged-chisellast Friday at 12:09 PM1 replyview on HN

I have never seen anyone argue for a ‘switch’ version.

    switch (v) {
     case: 0,2,4,8,…:
       return EVEN;
     case: 1,3,5,7,…:
       return ODD;
     default:
       return IDK;
    }
Slightly less code to generate.

Replies

willguestlast Friday at 12:57 PM

you forgot the logic to strip the final digit and assign it to v.

processing the whole number is absurd

show 3 replies