Last active
August 29, 2015 14:11
-
-
Save ttepasse/1c6dbc225aed56eec744 to your computer and use it in GitHub Desktop.
Optionals with boolean values
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
// The following would be great, if not for this error message | |
// “Extension of generic type Optional<T> from a different module cannot provide public declarations” | |
// | |
// ... which seems to be a bug in Swift: | |
// https://twitter.com/jckarter/status/513429427179356161 | |
extension Optional : BooleanType { | |
public var boolValue : Bool { | |
get { | |
switch (self) { | |
case .Some: | |
return true | |
case .None: | |
return false | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment