enum WeatherType {
case sun
case cloud
case rain
case wind
case snow
}
func getHaterStatus(weather: WeatherType) -> String? {
if weather == .sun {
return nil
} else {
return "Hate"
}
}
getHaterStatus(weather: .cloud)
// There is no way to do this. But there is a little workaround.
// Swift 5:
public enum Size: String {
case small = "small"
case medium = "medium"
case large = "large"
}
class SizeView: UIView {
private var size: Size = .large
@IBInspectable
public var sizeName: String = "large" {
didSet {
guard self.sizeName != oldValue else { return }
self.size = Size(rawValue: self.sizeName)
}
}
}
enum Season {
case spring, summer, autumn, winter
}