Usual classes can be deklared inside other classes or inside functions/methods. This is not the case for data classes. The following snippet doesn't compile:
fun main(args : Array<String>) {
data class User(val name: String, val age: Int)
}
Where the following was compiled without errors:
fun main(args : Array<String>) {
class User(val name: String, val age: Int)
}
I tried it with the “Kotlin Web Demo”.
Is this a bug or an undocumented limitation?
Cheers,
Christian