This is what I would like to do:
object foo {
def bar = Array(1, 2, 3, 4, 5)
}
class foo (baz = bar) {
}
This causes compiler errors. Is there another way to accomplish this?
object foo {
def bar = Array(1, 2, 3, 4, 5)
}
class foo (baz: Array[Int] = foo.bar) {
}
You can use an auxiliary constructor
object Foo {
def bar = Array(1, 2, 3, 4, 5)
}
class Foo(baz: Array[Int]) {
def this() = this(Foo.bar)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With