Last active
April 19, 2020 08:23
-
-
Save artem-smotrakov/eb018ebf2f321753eb71e5383bde5c7c to your computer and use it in GitHub Desktop.
What do you think is going to happen here? Options: compilation error, runtime error, it prints "Oops", it prints "OopsOops", it prints "Forty-two".
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
public class StrangeYield { | |
public static void main(String[] args) { | |
go(0); | |
} | |
static void go(int n) { | |
System.out.println( | |
switch (n) { | |
case 42 -> "Fotry-two"; | |
default -> { | |
yield("Oops"); | |
} | |
} | |
); | |
} | |
static String yield(String s) { | |
return s + "Oops"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment