Created
December 16, 2016 11:38
-
-
Save JimRoepcke/5ff39b17a836174c868708302bda6623 to your computer and use it in GitHub Desktop.
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
enum Bar: String { | |
case a, b, c | |
init?(w: Bool, x: Bool, y: Bool, z: Bool) { | |
if w { | |
if x { | |
self = .a | |
return | |
} else if y { | |
self = .b | |
return | |
} | |
//fall through | |
} | |
if z { | |
self = .c | |
return | |
} | |
return nil | |
} | |
} | |
enum Foo: String { | |
case a, b, c | |
init?(w: Bool, x: Bool, y: Bool, z: Bool) { | |
switch (w, x, y, z) { | |
case (true, true, _, _): | |
self = .a | |
case (true, false, true, _): | |
self = .b | |
case (_, _, _, true): | |
self = .c | |
default: | |
return nil | |
} | |
} | |
} | |
let f0 = Foo(w: false, x: false, y: false, z: false) | |
let f1 = Foo(w: false, x: false, y: false, z: true) | |
let f2 = Foo(w: false, x: false, y: true, z: false) | |
let f3 = Foo(w: false, x: false, y: true, z: true) | |
let f4 = Foo(w: false, x: true, y: false, z: false) | |
let f5 = Foo(w: false, x: true, y: false, z: true) | |
let f6 = Foo(w: false, x: true, y: true, z: false) | |
let f7 = Foo(w: false, x: true, y: true, z: true) | |
let f8 = Foo(w: true, x: false, y: false, z: false) | |
let f9 = Foo(w: true, x: false, y: false, z: true) | |
let fa = Foo(w: true, x: false, y: true, z: false) | |
let fb = Foo(w: true, x: false, y: true, z: true) | |
let fc = Foo(w: true, x: true, y: false, z: false) | |
let fd = Foo(w: true, x: true, y: false, z: true) | |
let fe = Foo(w: true, x: true, y: true, z: false) | |
let ff = Foo(w: true, x: true, y: true, z: true) | |
let b0 = Bar(w: false, x: false, y: false, z: false) | |
let b1 = Bar(w: false, x: false, y: false, z: true) | |
let b2 = Bar(w: false, x: false, y: true, z: false) | |
let b3 = Bar(w: false, x: false, y: true, z: true) | |
let b4 = Bar(w: false, x: true, y: false, z: false) | |
let b5 = Bar(w: false, x: true, y: false, z: true) | |
let b6 = Bar(w: false, x: true, y: true, z: false) | |
let b7 = Bar(w: false, x: true, y: true, z: true) | |
let b8 = Bar(w: true, x: false, y: false, z: false) | |
let b9 = Bar(w: true, x: false, y: false, z: true) | |
let ba = Bar(w: true, x: false, y: true, z: false) | |
let bb = Bar(w: true, x: false, y: true, z: true) | |
let bc = Bar(w: true, x: true, y: false, z: false) | |
let bd = Bar(w: true, x: true, y: false, z: true) | |
let be = Bar(w: true, x: true, y: true, z: false) | |
let bf = Bar(w: true, x: true, y: true, z: true) | |
f0?.rawValue == b0?.rawValue | |
f1?.rawValue == b1?.rawValue | |
f2?.rawValue == b2?.rawValue | |
f3?.rawValue == b3?.rawValue | |
f4?.rawValue == b4?.rawValue | |
f5?.rawValue == b5?.rawValue | |
f6?.rawValue == b6?.rawValue | |
f7?.rawValue == b7?.rawValue | |
f8?.rawValue == b8?.rawValue | |
f9?.rawValue == b9?.rawValue | |
fa?.rawValue == ba?.rawValue | |
fb?.rawValue == bb?.rawValue | |
fc?.rawValue == bc?.rawValue | |
fd?.rawValue == bd?.rawValue | |
fe?.rawValue == be?.rawValue | |
ff?.rawValue == bf?.rawValue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment