Skip to content

Instantly share code, notes, and snippets.

@Hadevs
Created November 26, 2018 16:34
Show Gist options
  • Save Hadevs/e983430f2f7ea24cf6e944fac2949d64 to your computer and use it in GitHub Desktop.
Save Hadevs/e983430f2f7ea24cf6e944fac2949d64 to your computer and use it in GitHub Desktop.
import Foundation
extension Optional where Wrapped == Bool {
static prefix func !(value: Bool?) -> Bool? {
return value.flatMap { !$0 }
}
}
var isOn: Bool? = nil
isOn = true
print(!isOn) // false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment