【发布时间】:2018-06-29 06:40:13
【问题描述】:
我正在尝试实现一个功能:
def foo(t : Class)
if t in Int::Signed
# ...
end
end
但是如何实现t in Int::Signed?在哪里Int::Signed
我知道is_a?(Int::Signed),但这里的参数是Type 类型。
谢谢。
【问题讨论】:
-
我也知道
case when,但是我觉得太长太丑了。 -
@Amadan 抱歉,我是
Class。我已经纠正了我的问题。但是typeof(1_64) == Int::Signed返回false。
标签: types crystal-lang