Skip to content

Instantly share code, notes, and snippets.

@sergi
Created October 30, 2012 13:19
Show Gist options
  • Save sergi/3980137 to your computer and use it in GitHub Desktop.
Save sergi/3980137 to your computer and use it in GitHub Desktop.
Test creating
macro val {
case $var:ident = $expr => {
var $var = $expr
}
case $var:ident = $x:lit .. $y:lit => {
var $var = (function() {
var arr = []
for (var i = $x; i < $y; i++)
arr.push(i)
return arr
})();
}
}
// This snippet below doesn't match
val a = 10;
console.log(a);
// This works nicely
val r = 10 .. 25
console.log(r)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment