Using Generic with inner constants

I must be missing something, but is there a way to do this?

class Foo(T)
  BOX = [] of T
end

# undefined constant T
#alias Toy = Foo(String)
#Toy::BOX

# syntax error
#Foo(String)::BOX

# undefined constant T
#Foo::BOX(String)

I want to be able to access the BOX constant, but each of these ways seems to throw an error.

1 Like

Generics can’t have generic constants, sorry. You can do Foo::BOX but T doesn’t exist there.

1 Like

Cool, thanks. I think I can do a work around.