Dai
Dai
Aug 24, 2017 · 1 min read

Nice! You could also potentially return FragmentTransaction from your lambda extension and then have your transaction chain like it does currently

inline internal fun FragmentManager.transaction(func: FragmentTransaction.() -> FragmentTransaction) {
// Chained
beginTransaction().func().commit()
}

Anyone reading may be interested to see you can do a similar thing with SharedPreferences:

inline internal fun SharedPreferences.applyMe(func: SharedPreferences.Editor.() -> SharedPreferences.Editor) {
this.edit().func().apply()
}
preferences.applyMe {
putBoolean("SOMETHING", true)
}

)

Dai

Written by

Dai

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade