https://kotlinlang.org logo
#announcements
Title
# announcements
k

karelpeeters

09/15/2017, 3:31 PM
Sure, but one might argue that
Person("Dave", age = 30)
is also resolvable at compile-time. Is there anything else that requires
const
?
r

Ruckus

09/15/2017, 3:38 PM
One would be wrong
k

karelpeeters

09/15/2017, 3:39 PM
Of course, I was just arguing that Jake's explenation wasn't really intuitive for a beginner.
b

benleggiero

09/15/2017, 4:41 PM
Person("Dave", age = 30)
could also invoke a
init
block, adding logic that can't be known at compile time, such as serialization, network requests, and GUI operations
👍 1
k

karelpeeters

09/15/2017, 4:43 PM
Let's say for he purpopses of my argument there's
data class Person(val name: String, val age: Int)
right below it.
b

benleggiero

09/15/2017, 5:03 PM
Yes, but this is still perfectly valid:
Copy code
data class Person(val name: String, val age: Int) {
    init {
        println("Oops")
    }
}
Perhaps a
const data class
that doesn't allow any initializer logic, and whose parameters must be
const
as well?
this is starting to sound a lot like that
inline data class
idea
1