Created
November 29, 2016 15:47
-
-
Save neovintage/3858bf0a88698acf98a0712e54a70b8a to your computer and use it in GitHub Desktop.
Generics and Constants
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 Something(T) | |
macro extended | |
alias Somethingelse = ({{ @type.id }} | Nil) | |
WHATEVER = [] of Somethingelse | |
def self.add(item : Somethingelse) | |
WHATEVER.push(item) | |
end | |
end | |
end | |
class Rimas | |
extend Something(Rimas) | |
def self.runit | |
r = Rimas.new | |
add(r) | |
WHATEVER.each do |item| | |
if !item.nil? | |
item.doit | |
end | |
end | |
end | |
def doit | |
puts "doit" | |
end | |
end | |
Rimas.runit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment