Reputation: 13686
Excuse the mind blank.
class Bar(implicit foo: Foo)
class Foo {
implicit val self = this
lazy val bar = new Bar
}
Can we simplify the instantiation of Bar
to a single statement where this
is provided very explicitly as the constructor argument?
My question also applies to passing any val, not only a this
as in this example.
Upvotes: 3
Views: 50
Reputation: 262464
The implicit parameter in your constructor is part of the second set of parameters here (the first set is empty), so you can do
val bar = new Bar()(new Foo)
Upvotes: 3