Raghu Nittala
09/20/2024, 1:29 PM@ConfigProperty(name = "event-enabled")
lateinit var eventEnabled: Boolean
For all the other types like String I’m able to do it. But for Boolean it fails with the error “‘lateinit’ modifier is not allowed on properties of primitive types”. I tried by removing lateinit, and it is giving me initialization errors. Can someone please help me on this?ephemient
09/20/2024, 1:47 PMlateinit
doesn't work for primitives or nullables. it's basically a nullable field under the covers, with a null check on every read. you can replace it with
var eventEnabled: Boolean = false
if you don't need to be guarded against read-before-initialization,ephemient
09/20/2024, 1:48 PMvar eventEnabled: Boolean by Delegates.notNull()
if you do, orephemient
09/20/2024, 1:48 PMvar eventEnabled: Boolean? = null
with a eventEnabled!!
check on read, for less overhead than delegatesRaghu Nittala
09/20/2024, 1:50 PMephemient
09/20/2024, 1:53 PMRaghu Nittala
09/20/2024, 1:55 PMKlitos Kyriacou
09/20/2024, 2:00 PMMichael Krussel
09/20/2024, 2:05 PMKlitos Kyriacou
09/20/2024, 2:15 PMval flags: EnumSet<FooBarOptions>
Raghu Nittala
09/20/2024, 2:26 PMRaghu Nittala
09/20/2024, 2:26 PMephemient
09/20/2024, 2:26 PMephemient
09/20/2024, 2:27 PMRaghu Nittala
09/20/2024, 2:28 PMRaghu Nittala
09/20/2024, 2:28 PM