Created
October 4, 2018 15:24
-
-
Save vishna/0bebef1aa2747b4478bdd634b2c6c2b4 to your computer and use it in GitHub Desktop.
Better safe than sorry
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
inline fun <T> safe(block: () -> T?) : T? { | |
return try { | |
block.invoke() | |
} catch (t: Throwable) { | |
null // ¯\_(ツ)_/¯ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment