You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Switch2.java 470B

12345678910111213141516171819202122232425262728
  1. public class Switch2 {
  2. public static void main(String[] argv) {
  3. System.out.println(one(Color.R));
  4. System.out.println(one(Color.G));
  5. System.out.println(one(Color.B));
  6. System.out.println(one(Color.Y));
  7. }
  8. public static int one(Color color) {
  9. int result = switch(color) {
  10. case R -> 0;
  11. case G -> 1;
  12. case B -> 2;
  13. default -> 3;
  14. };
  15. return result;
  16. }
  17. }
  18. enum Color {
  19. R, G, B, Y;
  20. }
  21. aspect X {
  22. int around(): call(* one(..)) {
  23. return proceed()*2;
  24. }
  25. }