I have the following enum and it works. However, is there a way that I can simply change Int and make it String and then directly assign?
is not it the following to wordy ? Companies(rawValue: httpMethod.self.rawValue)!
compared to Companies.stringValue
How could I call the following to get the String value?
public enum Companies: String {
case oil = "OIL"
case tech = "TECH"
case government = "GOVERNMENT"
case restaurant = "RESTAURANT"
}
The following works!
public enum Companies: Int {
case oil
case tech
case government
case restaurant
var stringValue: String {
switch self {
case .oil:
return "OIL"
case .tech:
return "TECH"
case .government:
return "GOVERNMENT"
case .restaurant:
return "RESTAURANT"
}
}
}
I could simply call Companies.stringValue