This file contains 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
Protocols and Extensions | |
Use protocol to declare a protocol. | |
protocol ExampleProtocol { | |
var simpleDescription: String { get } | |
mutating func adjust() | |
} | |
Classes, enumerations, and structs can all adopt protocols. |
This file contains 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
/*: | |
## Exercise: Leap Years | |
To decide if a year is a leap year, there are several decisions that have to be made: | |
- Is the year divisible by 4? | |
- If so, is the year divisible by 100? | |
- If not, it is a leap year. | |
- If so, is the year divisible by 400? | |
- If not, it is **not** a leap year. |