3 ms·
Yes. The problem with the switch is that in Scala, 'match' actually requires you to have at least one pattern matching rule. The closest I'd wrote in Scala to
by tommorris 13y ago
Yes. The problem with the switch is that in Scala, 'match' actually requires you to have at least one pattern matching rule.
The closest I'd wrote in Scala to your example is something like this:
def main(args: Array[String]) = {
42 match {case i: Any => None}
println("Hello World!")
}
Ideally, the switch (42) {} should be removed as it's not doing anything.
- ben0x539 13y agoSorry, maybe I minimized my example too eagerly. class HelloWorldApp { public static void main(String[] args) { switch (args.length) { case 0: System.out.println("No args!"); break; case 1: System.out.println("One arg!"); break; default: System.out.println("Multiple args!"); break; } System.out.println("Hello World!"); } } This also seems to not emit the "Hello World" println.