Skip to content

Instantly share code, notes, and snippets.

@sliskiCode
Last active December 11, 2017 09:38
Show Gist options
  • Select an option

  • Save sliskiCode/0c19c29bc0baafff35e847eab02a0a0b to your computer and use it in GitHub Desktop.

Select an option

Save sliskiCode/0c19c29bc0baafff35e847eab02a0a0b to your computer and use it in GitHub Desktop.
6 magic sugars that can make your Kotlin codebase happier #17
fun <T> withCorrectType(toBeChecked: Item, block: (T) -> Unit) {
if (toBeChecked !is T) {
throw IllegalArgumentException("Invalid type")
}
block.invoke(toBeChecked)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment