Crystal lang : 类型算术,属于一个Union?

Crystal lang : Type arithmetic, belongs to a Union?

我正在尝试实现一个功能:

def foo(t : Class)
    if t in Int::Signed
        # ...
    end
end

但是如何实现t in Int::Signed呢?其中 Int::Signed

我知道is_a?(Int::Signed)但是这里参数的类型是Type。 谢谢。

def foo(t : Class)
  if t < Int::Signed
    # ...
  end
end

Class#< 仅在 Crystal 0.25 中添加,如果我没记错的话,如果它对您不起作用,请务必更新。还有 Class#<= 会 return true for Int::Signed <= Int::Signed.