Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CatFragment: Fragment() {
- companion object {
- fun newInstance(catId: String) = CatFragment().withArgs {
- putString("catId", catId)
- }
- }
- }
- class DogFragment: Fragment() {
- companion object {
- fun newInstance(dogId: String) = DogFragment().withArgs {
- putString("dogId", dogId)
- }
- }
- }
- inline fun <T: Fragment> T.withArgs(
- argsBuilder: Bundle.() -> Unit): T =
- this.apply {
- arguments = Bundle().apply(argsBuilder)
- }
- // if(something != null && something.thingy) {
- // ...
- // } else {
- // ...
- // }
- something?.takeIf { it.thingy }?.let {
- ...
- } ?: {
- ...
- }
Add Comment
Please, Sign In to add comment