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

Vinicius Araujo

10/12/2019, 2:12 PM
Hi people, classes
init
blocks are not executed in casts right? Is there a way I could achieve it?
d

Dominaezzz

10/12/2019, 2:18 PM
init
does not support this. What specifically are you trying to achieve by doing this?
v

Vinicius Araujo

10/12/2019, 2:25 PM
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

Dominaezzz

10/12/2019, 2:42 PM
Cast from JSON? Is this Kotlin/JS?
If it is, easiest way I can think of is to cast and then call
copy()
.
v

Vinicius Araujo

10/12/2019, 2:54 PM
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
3 Views