Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ColeTownsend/ce608fb1c8537891ef41 to your computer and use it in GitHub Desktop.
Save ColeTownsend/ce608fb1c8537891ef41 to your computer and use it in GitHub Desktop.
import Foundation
let newSnow = 15
let currentWeatherType = "snow"
let temp = 32
enum NewSnowAmounts: Int {
case None, Little, Alot
}
enum WeatherTypes: String {
case Good, Bad, Decent
}
struct NewSnowPoints {
let amount: Int
var status: NewSnowAmounts {
switch amount {
case _ where amount > 10:
return .Alot
case _ where amount > 5:
return .Little
default:
return .None
}
}
init(amount: Int) {
self.amount = amount
}
}
struct WeatherPoints {
let type: String
let points: Float
var foo: WeatherTypes {
switch type {
case "clear-day", "clear-night", "snow":
return .Good
case "sleet", "wind", "fog", "rain":
return .Bad
default:
return .Decent
}
}
init(type: String, points: Float) {
self.type = type
self.points = points
}
}
let weather = WeatherPoints(type: currentWeatherType, points: 2)
weather.foo
let snow = NewSnowPoints(amount: newSnow)
snow.status
if (snow.status == NewSnowAmounts.Alot && weather.foo == WeatherTypes.Good) {
print("Go out!", terminator:"")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment