0
私は現在、Android用のちょっとしたスケーラDSL(https://github.com/bertderbecker/scalandroid)に取り組んでいます。スカラ:暗黙のコンストラクタパラメータをオーバーライドする方法は?
val drawerLayout = new SDrawerLayout {
openDrawerFrom = SGravity.LEFT
fitsSystemWindows = true
navigationView = new SNavigationView {
println(parent) //None - the parent of the drawerlayout
// I want that the parent is the drawerlayout
layout = SLayout.NAVI_HEADER_DEFAULT
fitsSystemWindows = true
}
}
は、どのように私は、その親、DrawerLayoutのない親としてSDrawerLayoutを使用するSNavigationViewを伝えることができますか?
もっと一般的には、暗黙的なパラメータとしてfoo(-1)をとり、foo(+1)を定義することができますfoo(0)を持つクラスfoo 0)を暗黙のパラメータとして指定します。
だから、fooは「再帰的」です。私が欲しいもの
は次のとおりです。
class foo()(implicit parent: foo) {
parent = this
val f = new Foo { //takes this as its parent
}
}
が暗黙のメソッドを使用します! –