Skip to content

Instantly share code, notes, and snippets.

@gabro gabro/iff.js forked from utaal/iff.js
Last active Aug 29, 2015

Embed
What would you like to do?
let if = macro {
rule {
($x:expr) {
$truebody
...
$truelast:expr
} else {
$falsebody
...
$falselast:expr
}
} => {
(function() {
var res = null;
if ($x) {
$truebody
...
res = $truelast;
} else {
$falsebody
...
res = $falselast
}
return res;
}())
}
}
var fortytwo = 42;
console.log(if(fortytwo == 42) {
var temp = fortytwo + 2;
"" + temp
} else {
null;
"not!"
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.