Created
August 10, 2015 11:29
-
-
Save itang/09fb2011c38f71377f58 to your computer and use it in GitHub Desktop.
Test Crystal macro reflect
This file contains 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 new_instance(clazz, args) | |
{{clazz.id}}.new({{*args}}) | |
end | |
module Util | |
class A | |
getter msg | |
def initialize(@msg) | |
end | |
end | |
end | |
m = "Hello #{Time.now}" | |
a = new_instance("Util::A", [m]) | |
puts a.msg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment