jasonlow
06/08/2017, 7:51 AMguard-else
statement, hence why I have something like this for my Kotlin 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 ?: ""
}