Last active
August 29, 2015 14:19
-
-
Save raindev/603dee4c27f5b0079151 to your computer and use it in GitHub Desktop.
Java let form
This file contains hidden or 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
// implementation | |
<T> void let(T value, Consumer<T> consumer) { | |
consumer.accept( value ); | |
} | |
// example usage | |
let(userService.findUser(), user -> { | |
// do something to the user | |
if (!user.isValid()) { | |
userService.removeUser(user); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is what could be achieved with lambda:
Agh 😯 Ugly!
Sadly, something like that won't work: