Starting to learn Scala, I would like to quickly see the method signature in the console. For example, in Haskell, I would do:
Prelude> :t map map :: (a -> b) -> [a] -> [b]
This clearly shows the signature of the mapping function, i.e.:
- A function that takes a and returns b
- List
and returns
which leads to the conclusion that map converts list a to list b, applying a function to each element of the list.
Is there a way to get a method type in a similar way in Scala?
UPDATE:
Attempted response by Federico Dahl Maso and getting this
scala> :type Array.fill <console>:8: error: ambiguous reference to overloaded definition, both method fill in object Array of type [T](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int)(elem: => T)(implicit evidence$13: scala.reflect.ClassManifest[T])Array[Array[Array[Array[Array[T]]]]] and method fill in object Array of type [T](n1: Int, n2: Int, n3: Int, n4: Int)(elem: => T)(implicit evidence$12: scala.reflect.ClassManifest[T])Array[Array[Array[Array[T]]]] match expected type ? Array.fill
Obviously, the padding method is overloaded and: type cannot decide which overload to display. So, is there a way to display the types of all method overloads?
source share