I have an enum of String
type.I want to prepend a string to all cases in this particular enum.
enum MyEnum: String, CaseIterable {
case root = "/"
case path1 = "/path"
}
The output I want is something like
enum MyEnum: String, CaseIterable {
case root = "myCustomString/"
case path1 = "myCustomString/path"
}
Is it possible to modify an associated value of a case of a String
enum?
func modifyEnumcases(string: String) {
/// append to each cases of an enum
}
modifyEnumcases("MyCustomString")
I tried doing it this way link
but this is not the use case I want to achieve.