Created
February 25, 2019 10:39
-
-
Save shkschneider/f6b0f441d48b4f89779699e6acaeee45 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
inline fun <reified T: Any> Fragment.extra(key: String, default: T? = null) = lazy { | |
val value = arguments?.get(key) | |
if (value is T) value else default | |
} | |
inline fun <reified T: Any> Fragment.extraNotNull(key: String, default: T? = null) = lazy { | |
val value = arguments?.get(key) | |
requireNotNull(if (value is T) value else default) { key } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment