Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Scala中检查函数类型_Scala - Fatal编程技术网

在Scala中检查函数类型

在Scala中检查函数类型,scala,Scala,在Haskell中,我可以使用:t在ghci中检查函数的类型: Prelude> :t odd odd :: Integral a => a -> Bool 这表示函数odd采用Integral类型并返回Bool。Scala有类似的功能吗?在Scala REPL中实际上是完全相同的: scala> def odd(x : Int) = x % 2 != 0 odd: (x: Int)Boolean scala> :t odd (x: Int)Boolean 这

在Haskell中,我可以使用
:t
ghci
中检查函数的类型:

Prelude> :t odd
odd :: Integral a => a -> Bool

这表示函数
odd
采用
Integral
类型并返回
Bool
。Scala有类似的功能吗?

在Scala REPL中实际上是完全相同的:

scala> def odd(x : Int) = x % 2 != 0
odd: (x: Int)Boolean

scala> :t odd
(x: Int)Boolean

这是最近增加的吗?我在scala 2.8.1中没有看到它。@VladtheImpala REPL在不断发展。@VladtheImpala我也因为同样的原因感到困惑;它不在Scala2.8.1中,但在Scala2.9.1中。嗯