Questions tagged «scala-primary-constructor»

2
Scala构造函数参数默认为private val吗?
我已经试了: class Foo(bar: Int) vs: class Foo(private val bar: Int) 他们似乎有同样的表现,虽然我无法找到任何地方说,(bar: Int)扩张到(private val bar: Int),所以我的问题是,这些相同/相似? 顺便说一句,我一直试图-Xprint:typer在这些代码段上使用,它们产生相同的代码,除了第二行中的额外一行。我如何阅读多余的文字? .. class Foo extends scala.AnyRef { <paramaccessor> private[this] val bar: Int = _; def <init>(bar: Int): this.Foo = { Foo.super.<init>(); () } } .. .. class Foo extends scala.AnyRef { <paramaccessor> private[this] val bar: …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.