Last active
December 11, 2017 09:38
-
-
Save sliskiCode/0c19c29bc0baafff35e847eab02a0a0b to your computer and use it in GitHub Desktop.
6 magic sugars that can make your Kotlin codebase happier #17
This file contains hidden or 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
| 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