Initializing a property with `run` and having an a...
# announcements
k
Initializing a property with
run
and having an accessor looks really bad, what format would you propose?
Copy code
var user: User = run {
    val userString = prefs.getString(USER, null)
    if (userString != null) {
        jsonAdapter.fromJson(userString)
    } else {
        User()
    }
}
    set(value) {
        field = value
        prefs.edit().putString(USER, jsonAdapter.toJson(user)).apply()
    }
Taken from http://stackoverflow.com/a/36126663/615306