Skip to content

Instantly share code, notes, and snippets.

@chrene
Created February 18, 2016 14:08
Show Gist options
  • Save chrene/0ca4a3d228ea794d5377 to your computer and use it in GitHub Desktop.
Save chrene/0ca4a3d228ea794d5377 to your computer and use it in GitHub Desktop.
import Foundation
extension ImplicitlyUnwrappedOptional: BooleanType {
/// Gets the boolean value of an implicitly unwrapped optional type
/// For all .None or nil values return false. Otherwise return true
public var boolValue: Bool {
return self != nil
}
}
extension Optional : BooleanType {
/// Gets the boolean value of an optional type
/// For all .None or nil values return false. Otherwise return true
public var boolValue: Bool {
return self != nil
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment