ClassyPimp
ClassyPimp

Reputation: 725

Can variable type in Crystal lang be restricted to classes that inherit from one class

I mean:

class Foo; end
class Bar < Foo; end
class Cux < Foo; end

Is it possible to restrict type of the variable to classes inheriting from Foo without unions, something like x : Foo+?

Upvotes: 0

Views: 109

Answers (1)

asterite
asterite

Reputation: 2926

Maybe using a type restriction?

@x : Foo

Upvotes: 1

Related Questions