oday
04/17/2019, 8:07 AMIgor Khvostenkov
04/17/2019, 8:28 AMString
and Int
or lateinit
for non primitives. lateinit var smth: String
var smth: String = ""
var smth: Int = 0
oday
04/17/2019, 8:52 AMIgor Khvostenkov
04/17/2019, 8:56 AMDaniel Garibaldi
04/17/2019, 10:56 AMNezteb
04/23/2019, 8:01 PMinit { }
block in the class, you can just make them all val thing: String
and it won’t complain because they will always be initializedvar thing: String? = null
is basically the equivalent in Java because anything can be null. You’re just forced to acknowledge it in Kotlin.data class
. That screenshot only shows a bunch of properties, which data classes are perfect for wrapping. Assuming this isn’t a huge class with lots of methods.oday
04/27/2019, 2:30 PMNezteb
04/30/2019, 7:33 PMdata class
for all of that.
data class ClassConfig(...)
class MyClass {
val config = ClassConfig(
....
)
// Functions here...
}