Created
July 16, 2011 01:12
-
-
Save aseemk/1085874 to your computer and use it in GitHub Desktop.
Streamline bug due to switch case w/out a break (CoffeeScript optimization)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async = (_) -> | |
setTimeout _, 1000 | |
switch true | |
when true | |
alert 'about to start async' | |
async _ | |
# this never executes! | |
alert 'done w/ async' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function async(_) { | |
setTimeout(_, 1000); | |
} | |
switch (true) { | |
case true: | |
alert('about to start async'); | |
async(_); | |
} | |
// this never executes! | |
alert('done w/ async'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function async(_) { | |
setTimeout(_, 1000); | |
} | |
switch (true) { | |
case true: | |
alert('about to start async'); | |
async(_); | |
// but when we add this explicit break: | |
break; | |
} | |
// this does execute now: | |
alert('done w/ async'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment