Skip to content

Commit

Permalink
Preferences.get minor refactor. #255
Browse files Browse the repository at this point in the history
  • Loading branch information
czyzby committed Sep 30, 2021
1 parent 5f35a21 commit 85678e1
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions preferences/src/main/kotlin/ktx/preferences/preferences.kt
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ inline operator fun <reified T> Preferences.get(key: String): T? =
* and converted to [Double]. Consider using a JSON-serializable object if you need to store [Double] values
* with high precision.
*/
inline operator fun <reified T> Preferences.get(key: String, defaultValue: T): T =
if (key in this) this[key]!! else defaultValue
inline operator fun <reified T> Preferences.get(key: String, defaultValue: T): T = this[key] ?: defaultValue

/**
* Calls [Preferences.flush] after executing the given [operations].
Expand Down

0 comments on commit 85678e1

Please sign in to comment.