Created
          February 6, 2020 22:00 
        
      - 
      
- 
        Save rzwitserloot/c747b45c33d1055d4fbfe64a450c897a to your computer and use it in GitHub Desktop. 
  
    
      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
    
  
  
    
  | @FunctionalInterface interface BetterRunnable<E extends Throwable> { | |
| void run() throws E; | |
| } | |
| public class BetterLambdaThrow { | |
| static <E extends Throwable> void runTwice(BetterRunnable<E> r) throws E { | |
| r.run(); | |
| r.run(); | |
| } | |
| public static void main(String[] args) { | |
| runTwice(() -> System.out.println("Hello, World!")); | |
| try { | |
| runTwice(() -> {throw new java.io.IOException();}); | |
| } catch (java.io.IOException e) { | |
| System.out.println("caught"); | |
| } | |
| } | |
| } | |
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment