I have the following problem: We have a shared scala-java-project (with members who only write java code), therefore we use java enumerations for one purpose. But now I want to perform pattern matching in scala on this enumeration, and optimize it with @switch, since the java switch actually can use enums.
But the compiler only complains:
error: could not emit switch for @switch annotated match
(args.tileType: @switch) match {
where tiletype is the field which contains one of the enum values. How to fix that the code can be optimized?
You use Java.
Scala contains only approximately the minimum necessary to be able to read Java enums. You can't create or optimizedly use them in Scala at present (through 2.10).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With