Skip to content

Instantly share code, notes, and snippets.

@gtomek
Forked from shkschneider/MyActivity.kt
Created March 6, 2019 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gtomek/242c3de7dc319daf04a4f37ed0a283c2 to your computer and use it in GitHub Desktop.
Save gtomek/242c3de7dc319daf04a4f37ed0a283c2 to your computer and use it in GitHub Desktop.
const val ID = "id"
class MyActivity : Activity() {
private val id1 by extra<String>(ID) // String?
private val id2 by extraNotNull<String>(ID) // String
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
requireNotNull(id1, id2)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment