How to find out the type of scala function

I would like to know the type of scala function in repl. In Haskell it is: t, can anyone say that this is equivalent in scala?

+5
source share
1 answer

There are two ways to find out. When you enter an expression, it tells the type:

scala> val f: Int => Int => Int = a => b => a + b f: Int => (Int => Int) = $$Lambda$1143/ 444402847@2b1a901d 

If you have an existing value and want to know its type, you use :type

 scala> :type f Int => (Int => Int) 

Or, as others say :t also works like Haskell:

 scala> :tf Int => (Int => Int) 
+8
source

Source: https://habr.com/ru/post/1269960/


All Articles