Is there a way to get the name of 'this' in an extension function?
fun Boolean?.persist() {
if (this == null) return // Do Nothing
val nameOfVariable:String = //get the name of the variable?
// Persist variable
PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean(nameOfVariable, this).apply()
}
Aucun commentaire:
Enregistrer un commentaire