I have enum class with method declared inside
enum class MyEnum {
VAL1, VAL2, VAL3;
fun myFunc(): Any{
// Here I want to access selected value
// VAL1 in my example
}
}
I can call this method like this
MyEnum.VAL1.myFunc()
But is it possible inside myFunc to get the value method was called on? In my example it's VAL1.
this? What's the context of referencing self? If it's to return some value based on "selected" value with a switch (when), then it's better to have a field in the enum and just return its value.