Last active
August 29, 2015 13:56
-
-
Save ponkotuy/9225301 to your computer and use it in GitHub Desktop.
補助コンストラクタでなぜかcompileできないパターン
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Main extends App { | |
val hoge = new Hoge() | |
println((hoge.hoge, hoge.fuga)) | |
} | |
class Hoge(val hoge: Int, val fuga: Int) { | |
import Hoge._ | |
def this() = this(init, init) // Compile Erorr! not found init | |
} | |
object Hoge { | |
val init = 1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Main extends App { | |
val hoge = new Hoge() | |
println((hoge.hoge, hoge.fuga)) | |
} | |
class Hoge(val hoge: Int, val fuga: Int) { | |
def this() = { | |
import Hoge._ // Compile Error! this expected but import found | |
this(init, init) | |
} | |
} | |
object Hoge { | |
val init = 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
あれ、嘘つきましたね。 this 先に呼び出せば処理かけますね。