I want to create a class with a public enum (to be used by other modules) with an internal String raw value (I don't want other modules to read the raw Value, but I do want to read it internally inside the same module).
I know I can just create another private function that receives the enum and returns a String but I want to avoid that.
I think it's not possible, I tried doing like this first:
public enum Emotion {
case Hate = EmotionInner.Hate, Love = EmotionInner.Love
}
internal enum EmotionInner: String {
case Hate = "hate", Love = "love"
}
But it won't compile.
Your enums at least should be the same type - so if you want to has rawValue() it will has it in both enum. And you can't make rawValue() smth like final or static.
By the way, maybe it's not bad way to make a function for it?
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