Skip to content

Instantly share code, notes, and snippets.

@wmoxam
Created April 17, 2016 23:29
Show Gist options
  • Select an option

  • Save wmoxam/973e3d12204c8200ea39eda8382ae635 to your computer and use it in GitHub Desktop.

Select an option

Save wmoxam/973e3d12204c8200ea39eda8382ae635 to your computer and use it in GitHub Desktop.
abstract class Base
end
class Example1 < Base
end
class Example2 < Base
end
class Test
setter :a
end
t1 = Test.new
t1.a = Example1
t2 = Test.new
t2.a = Example2
# crystal tool hierarchy test.cr
+- class Reference (4 bytes)
|
+- class Test (24 bytes)
| @a : Base+:Class? (16 bytes)
How can I specify an array of Base+:Class ?
klasses = [] of Base+
klasses << Example1
-- > no overload matches 'Array(Base+)#<<' with type Example1:Class
klasses = [] of Base+:Class
-- > unexpected token: Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment