Skip to content

Instantly share code, notes, and snippets.

View chibat's full-sized avatar
🟢
Perfect

Tomofumi Chiba chibat

🟢
Perfect
View GitHub Profile
@chibat
chibat / java-lambda-check-exception.md
Last active November 10, 2022 22:55
Java の lambda 内のチェック例外のウザさをなんとかする

Java の lambda 内のチェック例外のウザさをなんとかする

Java の Stream API などを使っていると、lambda 内のチェック例外がうざいです。

例えば、次のようなコードは、コンパイルエラーになります。

Stream.of("http://example.com").map(string -> {
  return new URL(string); // MalformedURLException を throw する可能性があるのでコンパイルエラー
});