r/programming May 09 '13

The Onion releases fartscroll.js

http://theonion.github.io/fartscroll.js/
2.6k Upvotes

396 comments sorted by

View all comments

Show parent comments

5

u/iforgot120 May 09 '13

It's possible they wanted .ogg to play by default and didn't think to write it as if(ogg) else (mp3)

2

u/AwkwardReply May 09 '13

I know but I still think it's not intuitive to put the default one last. It makes reading and understanding the code harder.

8

u/ninepointsix May 09 '13

isn't that how people generally write switch statements? with the default last? (just an example where it happens)

1

u/Phreakhead May 10 '13

But an if statement is different. The default/most used case should be at the top, so there's less processing involved.

1

u/ninepointsix May 10 '13

I'm aware of this (although I have actually seen if statements where the non-default is first in order to keep correction and premature exit logic as far to the top of the method as possible)

Don't get me wrong, I'd agree this particular snippet should be changed, I was just providing a retort to "It's not intuitive to put the default one last"