Skip to content

Instantly share code, notes, and snippets.

@meet30997
Created June 30, 2019 05:09
Show Gist options
  • Save meet30997/2a7f193f996f79b2bef752e694c820a9 to your computer and use it in GitHub Desktop.
Save meet30997/2a7f193f996f79b2bef752e694c820a9 to your computer and use it in GitHub Desktop.
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