So I'm using retrofit and created a custom class that extends the retrofit Callback and calls its own onSuccess function when response.isSuccessful is true, and otherwise calls its own onError function - I'm interfacing with an API that often returns http error codes, and this simplifies handling that. The problem (not really a problem, more of an inconvenience that I'd like to get around) is that sometimes response.body() is null (sometimes the API returns an empty body) and so I need to either always check for null when using the body in my custom callback's onSuccess, or I need to have multiple constructors for my callback, one that takes an onSuccess that's (T) -> Unit, and another that takes a () -> Unit for it's onSuccess, and then calls the appropriate one based on whether response.body() is null. Which also means I have to explicitly declare the parameters when passing the function to the constructor as a lambda, which is kind of annoying. Is there any way I could get around that? Is this even how I should be doing this?