3 ms·
I don't know scala so maybe I'm missing something, but does this just break with functions that start with a switch statement? eg. public static void m
by ben0x539 13y ago
I don't know scala so maybe I'm missing something, but does this just break with functions that start with a switch statement? eg.
public static void main(String[] args) {
switch (42) {}
System.out.println("Hello World!");
}
converts to
def main(args: Array[String]) 42 match {
}
dropping the println.
Edit: It also seems to be dropping autoincrement/decrement, and random other blocks of code I've looked at, so I guess it's still in a fairly early stage.
Definitely a cool project though :)
- tommorris 13y agoYes. 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.