Skip to content

Instantly share code, notes, and snippets.

@sliskiCode
Last active November 27, 2017 08:59
Show Gist options
  • Save sliskiCode/8ba139d23a7bfe67edc24d2e84103327 to your computer and use it in GitHub Desktop.
Save sliskiCode/8ba139d23a7bfe67edc24d2e84103327 to your computer and use it in GitHub Desktop.
6 magic sugars that can make your Kotlin codebase happier #5
public final void sugar(@NotNull Response response) {
Intrinsics.checkParameterIsNotNull(response, "response");
String var3;
if (response instanceof Success) {
var3 = ((Success)response).getBody();
System.out.println(var3);
} else if (response instanceof Error) {
var3 = "" + ((Error)response).getCode() + ' ' + ((Error)response).getMessage();
System.out.println(var3);
} else {
if (!Intrinsics.areEqual(response, Timeout.INSTANCE)) {
throw new NoWhenBranchMatchedException();
}
var3 = response.getClass().getSimpleName();
System.out.println(var3);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment