Created
July 11, 2018 14:14
-
-
Save fukaoi/742f71fdf3c930683e41a9b33448214a to your computer and use it in GitHub Desktop.
Macro example
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
| module Demo | |
| STRUCT = [ | |
| Bool, Char, Symbol, | |
| Int8, Int16, Int32, Int64, Int128, | |
| Float32, Float64 | |
| ] | |
| macro define_struct | |
| {% for s in STRUCT %} | |
| struct {{ s.id }} | |
| # | |
| # Override or define some method if it's needed | |
| # | |
| def clean; end | |
| end | |
| {% end %} | |
| {% debug %} | |
| end | |
| end | |
| Demo.define_struct |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment