Created
June 30, 2019 05:09
-
-
Save meet30997/2a7f193f996f79b2bef752e694c820a9 to your computer and use it in GitHub Desktop.
This file contains 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
package com.awesome.kotlindsl | |
import android.app.Activity | |
import android.content.Context | |
import android.content.Intent | |
import kotlin.contracts.ExperimentalContracts | |
import kotlin.contracts.InvocationKind | |
import kotlin.contracts.contract | |
@ExperimentalContracts | |
inline fun <T:Intent> T.putsome(block: Intent.() -> Unit): T { | |
contract { | |
callsInPlace(block, InvocationKind.EXACTLY_ONCE) | |
} | |
block() | |
return this | |
} | |
inline fun <reified T : Activity> Context.launched() = | |
Intent(this, T::class.java) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment