Skip to content

Instantly share code, notes, and snippets.

@sliskiCode
Last active November 27, 2017 08:59
Show Gist options
  • Save sliskiCode/aeebb2d444cbd41ec0a998b5a332f72e to your computer and use it in GitHub Desktop.
Save sliskiCode/aeebb2d444cbd41ec0a998b5a332f72e to your computer and use it in GitHub Desktop.
6 magic sugars that can make your Kotlin codebase happier #4
fun sugar(response: Response) = when (response) {
is Success -> println(response.body)
is Error -> println("${response.code} ${response.message}")
Timeout -> println(response.javaClass.simpleName)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment