Hi people, classes `init` blocks are not executed ...
# announcements
v
Hi people, classes
init
blocks are not executed in casts right? Is there a way I could achieve it?
d
init
does not support this. What specifically are you trying to achieve by doing this?
v
to make field verification of data class properties. Sometimes the object is created, which works fine, and sometimes it is casted from a JSON type, which doenst
d
Cast from JSON? Is this Kotlin/JS?
If it is, easiest way I can think of is to cast and then call
copy()
.
v
Yes it is kotlin's Ktor. I think I will create a
valid()
function and call it from init, and also when casting, thanks Dom