Skip to content

Instantly share code, notes, and snippets.

@hlung
Created May 3, 2019 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hlung/149af273423aa6356b246e5bf3821a71 to your computer and use it in GitHub Desktop.
Save hlung/149af273423aa6356b246e5bf3821a71 to your computer and use it in GitHub Desktop.
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