Created
May 3, 2019 11:29
-
-
Save hlung/149af273423aa6356b246e5bf3821a71 to your computer and use it in GitHub Desktop.
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
import Foundation | |
protocol Reversible { | |
var isOn: Bool { get set } | |
mutating func reverse() | |
func reversed() -> Self | |
} | |
extension Reversible { | |
mutating func reverse() { | |
isOn = !isOn | |
} | |
func reversed() -> Self { | |
var new = self | |
new.reverse() | |
return new | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment