Skip to content

Instantly share code, notes, and snippets.

@z64

z64/crystal.txt Secret

Created January 17, 2019 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save z64/eba030d96d822a220452cd912e944a89 to your computer and use it in GitHub Desktop.
Save z64/eba030d96d822a220452cd912e944a89 to your computer and use it in GitHub Desktop.
# cr getter.cr
nil
# crystal tool expand -c getter.cr:2:3 getter.cr
1 expansion found
expansion 1:
class_getter?(bar : String | ::Nil) do
"str"
end
# expand macro 'class_getter?' (/usr/lib/crystal/core/object.cr:230:3)
~> @@bar : String | ::Nil
def self.bar? : String | ::Nil
@@bar
end
class Foo
class_getter? bar : String? do
"str"
end
end
p Foo.bar?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment