Is there a way to override method in Scala 3 enum just like in Java?
public enum Test {
ONE {
@Override
public int calc() {
return 1;
}
},
TWO {
@Override
public int calc() {
return 2;
}
};
public abstract int calc();
}
I've tried something like this, but no result. Also haven't found anything about enum methods overriding in documentation.
enum Test {
def calc(): Int ={
0
}
case One
override def calc(): Int ={
1
}
case Two
override def calc(): Int ={
2
}
}
Maybe there is another way to achieve similar functionality?