根据,Schala方法属于一个类别。 然而,如果我界定了REPL的一种方法,或用我当时使用的卡片进行的描述,那么该方法属于哪一类?
scala> def hoho(str:String) = {println("hoho " + str)}
hoho: (str: String)Unit
scala> hoho("rahul")
hoho rahul
In this example, what class does the method belong to ?
根据,Schala方法属于一个类别。 然而,如果我界定了REPL的一种方法,或用我当时使用的卡片进行的描述,那么该方法属于哪一类?
scala> def hoho(str:String) = {println("hoho " + str)}
hoho: (str: String)Unit
scala> hoho("rahul")
hoho rahul
In this example, what class does the method belong to ?
REPL将你的所有发言(实际上改写了你的发言稿)以自动作成。 如果你使用<条码>-X印:typer 备选办法印刷中间代码,你可以认为该代码是有效的:
scala> def hoho(str:String) = {println("hoho " + str)}
[[syntax trees at end of typer]]// Scala source: <console>
package $line1 {
final object $read extends java.lang.Object with ScalaObject {
def this(): object $line1.$read = {
$read.super.this();
()
};
final object $iw extends java.lang.Object with ScalaObject {
def this(): object $line1.$read.$iw = {
$iw.super.this();
()
};
final object $iw extends java.lang.Object with ScalaObject {
def this(): object $line1.$read.$iw.$iw = {
$iw.super.this();
()
};
def hoho(str: String): Unit = scala.this.Predef.println("hoho ".+(str))
}
}
}
}
So your method hoho
is really $line1.$read.$iw.$iw.hoho
. Then when you use hoho("foo")
later on, it ll rewrite to add the package and outer objects.
附加说明:关于字母,-Xprint:typer
(-Xprint:parser/code>)显示,该代码在
或main(args:Array[String]
的正标栏内封顶内。 可查阅<代码>argsargv
。
I have 4 elements:List[List[Object]] (Objects are different in each element) that I want to zip so that I can have a List[List[obj1],List[obj2],List[obj3],List[obj4]] I tried to zip them and I ...
I m impressed with Twitter and investigating to use Scala for a new large scale web project with Hibernate and Wicket. What do you think about Scala, and should I use it instead of Java? EDIT: And, ...
I m going to work on comparing around 300 binary files using Scala, bytes-by-bytes, 4MB each. However, judging from what I ve already done, processing 15 files at the same time using java....
The scala type Nothing represents (as I understand it) the bottom of the type hierarchy, also denoted by the symbol ⊥. That is, Nothing is a sub-type of any given type. The requirement for a Nothing ...
When I execute a Scala script from the command line, a directory named "tmp" is created in my home directory. It is always empty, so I simply deleted it without any apparent problem. Of course, when I ...
Is it possible to include a jar file run running the Scala interpreter? My code is working when I compile from scalac: scalac script.scala -classpath *.jar But I would like to be able to include a ...
I am trying to use Scala s capabilty of running a class with either JUnit or ScalaTest. I took the example given for FeatureSpec and combined it with the example using JUnitSuite. I am having a ...
There are various answers on Stack Overflow which explain the conditions under which tail recursion is possible in Scala. I understand the limitations and how and where I can take advantage of tail ...