I'm learning Kotlin and would like to find out how to avoid creating an object if a function that is called inside an init block returns false. Basically, what I'd like to do is, if the function returns false, I'd throw the user an error and not create the object, but if it returns true, I'd create it. Does anyone know how I could solve this?
checkNotNull(fun)it's likecheck(), Otherwise returns the not null value.