From 05dcbe9d8c36d4e4007543cea6e968e6819d182a Mon Sep 17 00:00:00 2001 From: Maia Everett Date: Sat, 30 Aug 2025 19:44:33 +0300 Subject: [PATCH] Make switch consistent and add no_run where appropriate --- src/switch.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/switch.md b/src/switch.md index a182768..50a2fde 100644 --- a/src/switch.md +++ b/src/switch.md @@ -17,12 +17,12 @@ if (isLeapYear && !bloodMoon && (age > 30 || catName.equals("fred"))) { But it can be burdensome if all you are doing is checking if some variable has a particular value. -```java +```java,no_run ~void main() { if (food.equals("apple")) { IO.println("Red"); } -else if (name.equals("grape")) { +else if (food.equals("grape")) { IO.println("Purple"); } else if (food.equals("orange")) { @@ -36,7 +36,7 @@ else { For these situations, you can use a `switch`. -```java +```java,no_run switch (fruit) { case "apple" -> { IO.println("Red");