4
如果我編譯如下:爲什麼Kotlin init塊中不允許「return」?
class CsvFile(pathToFile : String)
{
init
{
if (!File(pathToFile).exists())
return
// Do something useful here
}
}
我得到一個錯誤:
Error:(18, 13) Kotlin: 'return' is not allowed here
我不想與編譯器爭論,但我很好奇這個限制背後的動機。