Skip to content

Instantly share code, notes, and snippets.

@bcardiff
Last active September 5, 2019 18:09
Show Gist options
  • Save bcardiff/05482bb9dddeacf41856 to your computer and use it in GitHub Desktop.
Save bcardiff/05482bb9dddeacf41856 to your computer and use it in GitHub Desktop.
for crystal
macro for(expr)
{{raise "invalid syntax. use for e in c." unless expr.args.first.name.stringify == "in"}}
{{expr.args.first.args.first}}.each do |{{expr.name.id}}|
{{expr.args.first.block.body}}
end
end
for e in 1..5 do
puts e
end
for e in [1,2,3,4] do
puts e
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment