For instance, after a HttpResponse is returned from a web server, I check the status code: if failure, then run failure method, else run success method. I can do that with an if statement. Using an if statement means that I have to query the status code. I can also do it with a Consumer and Runnable: onSuccess(action, otherwise). The status code still gets checked, but now that gets done in the appropriate place: the response checks it, or the code checks itself.
We see hints to this model in #Java's #Optional class, with its #ifPresent(Consumer) method, and its #ifPresentOrElse(Consumer, Runnable) method.
And it's a shame that we can't apply this model to Strings or anything else implementing an isEmpty() method: the Java #programming #language won't let us #subclass most of its core classes.
It feels easier to implement this in a #trait-based language like #RustLang.
Server run by the main developers of the project It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!