Created
September 26, 2017 23:09
-
-
Save faustinoaq/20c12653130282971ba8102d9e60c5c9 to your computer and use it in GitHub Desktop.
Compiled time array
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
A = [] of Nil | |
{% A << 0 %} | |
{% A << "Some String" %} | |
{% p A[0] %} # => 0 | |
{% p A[1] %} # => "Some String" |
When you don't use a constant it's not typed, so a constant can be used as a placeholder in macros
That is, when you don't use that constant at runtime
Also known has hack #123 (just kidding)
But Elixir does something similar, only with attributes (which only exist at compile-time, I think)
https://gitter.im/crystal-lang/crystal?at=59cac1267b7d98d30d3d2033
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://carc.in/#/r/2sv6