5
我想知道repl中scala函数的类型。在Haskell中,它是:t,任何人都可以在scala中说出它的等价物吗?我如何知道scala函数的类型
我想知道repl中scala函数的类型。在Haskell中,它是:t,任何人都可以在scala中说出它的等价物吗?我如何知道scala函数的类型
有两种方法可以知道。一旦你在表达式类型,它告诉类型:
scala> val f: Int => Int => Int = a => b => a + b
f: Int => (Int => Int) = $$Lambda$1143/[email protected]
如果你有一个现有的价值,想知道它的类型,您使用:type
scala> :type f
Int => (Int => Int)
或者为他人提,:t
也适用类似于Haskell:
scala> :t f
Int => (Int => Int)
'scala>:tf'也有效。 – chunjef
@chunjef更新。 –