Last active
October 26, 2017 15:43
-
-
Save soxjke/01327f4d078d26d4108f9346e597d6d6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum WeatherValue<Value> { | |
| case single(value: Value) | |
| case minmax(min: Value, max: Value) | |
| } | |
| struct WeatherFeature<T> { | |
| let unit: String | |
| let value: WeatherValue<T> | |
| } | |
| struct DayNightWeather { | |
| let windSpeed: WeatherFeature<Double> | |
| let windDirection: String | |
| let precipitationProbability: Int | |
| let phrase: String | |
| let icon: Int | |
| } | |
| // Since Swift 3.1 there's a neat feature called "Type nesting with generics" is | |
| // around, however implementation is buggy and leads to runtime error | |
| // https://bugs.swift.org/browse/SR-4383 | |
| // As a workaround, WeatherValue, WeatherFeature, DayNightWeather are standalone types | |
| struct Weather { | |
| let effectiveDate: Date | |
| let temperature: WeatherFeature<Double> | |
| let realFeel: WeatherFeature<Double> | |
| let day: DayNightWeather | |
| let night: DayNightWeather | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment