Created
February 12, 2016 16:41
-
-
Save dwaite/60c8dc05e498b747d0f2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
enum Booly { | |
case truth | |
case falsehood | |
static let yes:Booly = truth | |
static let no:Booly = falsehood | |
static func defaulted() -> Booly { | |
return truth | |
} | |
static func workingYesVersion() -> Booly { | |
return yes | |
} | |
} | |
extension Booly { | |
func isDefault() -> Bool { | |
return self == truth | |
} | |
func brokenYesVersion() -> Bool { | |
// return self == yes // Error: Static member 'yes' cannot be used on instance of type 'Booly' | |
return self == .yes | |
} | |
} | |
import Foundation | |
let flags:CFStringCompareFlags = [.CompareAnchored] | |
switch flags { | |
// case .CompareAnchored: // Error: Enum case 'CompareAnchored' ont found in type 'CFStringCompareFlags' | |
case CFStringCompareFlags.CompareAnchored: | |
print("Anchored") | |
default: | |
() | |
} | |
let b:Booly = .yes | |
// switch b { | |
// case yes: // Error: Use of unresolved identifier 'yes' | |
// case .yes: // Error: Enum case 'yes' not found in type 'Booly' | |
// case Booly.yes: // Error: Enum case 'yes' not found in type 'Booly' | |
//} | |
let externalYes = Booly.truth | |
switch b { | |
case externalYes: | |
print ("finally, yes!") | |
default: | |
() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment