I know Kotlin does not have a true `guard-else` s...
# android
j
I know Kotlin does not have a true
guard-else
statement, hence why I have something like this for my Kotlin code:
Copy code
constructor(json: JSONObject) : this() {
        val id = json.opt("id") ?: return

        when (id) {
            is Int -> this.id = id
            is String -> this.id = id.toInt()
        }

        this.name = json.opt("name") as? String ?: ""
        this.email = json.opt("email") as? String ?: ""
        this.phone = json.opt("phone") as? String ?: ""
        this.photoURL = json.opt("photo_url") as? String ?: ""
    }