Crystal lang 中的变量类型是否可以限制为继承自一个 class 的 classes
Can variable type in Crystal lang be restricted to classes that inherit from one class
我的意思是:
class Foo; end
class Bar < Foo; end
class Cux < Foo; end
是否可以将变量的类型限制为 类 继承自 Foo
而无需联合,例如 x : Foo+
?
可能使用类型限制?
@x : Foo
我的意思是:
class Foo; end
class Bar < Foo; end
class Cux < Foo; end
是否可以将变量的类型限制为 类 继承自 Foo
而无需联合,例如 x : Foo+
?
可能使用类型限制?
@x : Foo