Scala REPL: How to find function type?

心不动则不痛 提交于 2019-12-03 11:55:52

Following the suggestion will work pretty well:

:t inc _
Int => Int

To give a bit more detail, the reason this is necessary is that Scala maintains a distinction between 'methods', which have native support in the JVM but which are not first class, and 'functions', which are treated as instances of FunctionX and seen as objects by the JVM. The use of the trailing underscore converts the former to the latter.

Tabzz

You can write the name of the method and press tab.

Stream.fill<tab>

gives you:

def fill[A](n1: Int,n2: Int,n3: Int)(elem: => A): 
scala.collection.immutable.Stream[scala.collection.immutable.Stream[scala.collection.immutable.Stream[A]]]
def fill[A](n1: Int,n2: Int,n3: Int,n4: Int)(elem: => A): scala.collection.immutable.Stream[scala.collection.immutable.Stream[scala.collection.immutable.Stream[scala.collection.immutable.Stream[A]]]]
def fill[A](n1: Int,n2: Int)(elem: => A): scala.collection.immutable.Stream[scala.collection.immutable.Stream[A]]
def fill[A](n1: Int,n2: Int,n3: Int,n4: Int,n5: Int)(elem: => A): scala.collection.immutable.Stream[scala.collection.immutable.Stream[scala.collection.immutable.Stream[scala.collection.immutable.Stream[scala.collection.immutable.Stream[A]]]]]
override def fill[A](n: Int)(elem: => A): scala.collection.immutable.Stream[A]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!