Last active
July 16, 2024 01:10
-
-
Save Iainmon/2beb2a75c20f78408e39529db6a6dc74 to your computer and use it in GitHub Desktop.
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
| macro for(definition, condition, incrimentation, &block) | |
| {{definition}} | |
| while {{condition}} | |
| {{block.body}} | |
| {{incrimentation}} | |
| end | |
| end | |
| macro for(expr) | |
| ({{expr.args.first.args.first}}).each do |{{expr.name.id}}| | |
| {{expr.args.first.block.body}} | |
| end | |
| end | |
| # Regular for loop | |
| for x = 0, x < 5, x += 1 do | |
| puts x | |
| end | |
| # For-in loop | |
| for x in 1..5 do | |
| puts x | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment