Skip to content

Instantly share code, notes, and snippets.

@PHPirates
Last active March 7, 2018 19:11
Show Gist options
  • Save PHPirates/f53c2522fbccb598dc47dc820246d082 to your computer and use it in GitHub Desktop.
Save PHPirates/f53c2522fbccb598dc47dc820246d082 to your computer and use it in GitHub Desktop.
Example of use of replaceWith in Kotlin
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