Last active
June 1, 2019 14:46
-
-
Save stefanofago73/947c197760611f075bfe2d5542d7eb2b to your computer and use it in GitHub Desktop.
This file contains 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
package it.fago.experiment.autocloseable.dirty; | |
import java.util.function.BiFunction; | |
import java.util.function.Consumer; | |
public class AutoCloser{ | |
public static final <S> AutoCloseable autoclose(S element, Consumer<S> elementInvocation) { | |
return ((BiFunction<S, Consumer<S>, AutoCloseable>) (subject, callback) -> () -> callback.accept(subject)).apply(element, elementInvocation); | |
} | |
}// END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment