Skip to content

Instantly share code, notes, and snippets.

@neovintage
Created November 29, 2016 15:47
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 neovintage/3858bf0a88698acf98a0712e54a70b8a to your computer and use it in GitHub Desktop.
Save neovintage/3858bf0a88698acf98a0712e54a70b8a to your computer and use it in GitHub Desktop.
Generics and Constants
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