I have an enum defined as follows
enum Fruit {
case Apple(associatedValue: String)
case Orange(associatedValue: String)
}
I have a function that takes an argument of type Fruit
func printNameOnly(fruit: Fruit) {
}
In this function I want to get the enum case as a string, i.e. I want to get the string "Apple" or "Orange" without regard to whatever the associated value is. Is this possible with Swift?
I could obviously write a function which takes the fruit enum and returns a string using a case statement, but I am trying to find a way to avoid that since the string I want is the enum case name itself.