Challenge B: Computing with raw values

Taking the example from earlier in the chapter, begin with the Month enumeration:

enum Month: Int {

case january = 1, february, march, april, may, june, july, august, september, october, november, december

}

Write a computed property to calculate the number of months until summer.

Hint: You’ll need to account for a negative value if summer has already passed in the current year. To do that, imagine looping back around for the next full year.

results matching ""

    No results matching ""