Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stefanofago73/947c197760611f075bfe2d5542d7eb2b to your computer and use it in GitHub Desktop.
Save stefanofago73/947c197760611f075bfe2d5542d7eb2b to your computer and use it in GitHub Desktop.
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