Skip to content

Instantly share code, notes, and snippets.

View SBarkovskiy's full-sized avatar

Sergey Barkovskiy SBarkovskiy

View GitHub Profile
@SBarkovskiy
SBarkovskiy / Leap Years.txt
Last active September 21, 2017 19:23
Into to App Development with Swift Exercice 11 Leap Years
/*:
## 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.
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.