Skip to content

Instantly share code, notes, and snippets.

@fukaoi
Created July 11, 2018 14:14
Show Gist options
  • Select an option

  • Save fukaoi/742f71fdf3c930683e41a9b33448214a to your computer and use it in GitHub Desktop.

Select an option

Save fukaoi/742f71fdf3c930683e41a9b33448214a to your computer and use it in GitHub Desktop.
Macro example
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