Last active
March 7, 2018 19:11
-
-
Save PHPirates/f53c2522fbccb598dc47dc820246d082 to your computer and use it in GitHub Desktop.
Example of use of replaceWith in Kotlin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StuffContainer(val context: Context?) { | |
private val prefs = android.preference.PreferenceManager.getDefaultSharedPreferences(context) | |
/** This is stuff. */ | |
var stuff: Boolean | |
get() = prefs.getBoolean("stuffkey", false) | |
set(value) { | |
prefs.edit().putBoolean("stuffkey", value).apply() | |
} | |
/** | |
* Get stuff. | |
*/ | |
@Deprecated("use property", replaceWith = ReplaceWith("stuff")) | |
fun getStuff(): Boolean { | |
return prefs.getBoolean("stuffkey", false) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment