Skip to content

Instantly share code, notes, and snippets.

@oki
Created June 21, 2018 09:54
Show Gist options
  • Select an option

  • Save oki/73c8fd339bddf66863d2bbb7dc7ad622 to your computer and use it in GitHub Desktop.

Select an option

Save oki/73c8fd339bddf66863d2bbb7dc7ad622 to your computer and use it in GitHub Desktop.
class Class1
def dupa
puts "Dupa from Class1"
end
end
class Class2
def dupa
puts "Dupa from Class2"
end
end
alias Dupa = (Class1.class | Class2.class)
class Buzz
def initialize
# @arr = [] of (Class1.class | Class2.class)
@arr = [] of Dupa
end
def add(class_name : Class)
@arr << class_name
end
def run_dupas
@arr.each do |class_name|
class_name.new.dupa
end
end
def dump
pp @arr
end
end
buzz = Buzz.new
buzz.add(Class1)
buzz.add(Class2)
buzz.dump
buzz.run_dupas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment