I am having trouble figuring out how to use options inside a tuple inside a switch. The syntax below (let ...) ... works like not a tuple, but inside the tuple I get the expected separator material: (
var dict = Dictionary<String,Bool>() dict["a"] = true switch (dict["a"],dict["b") { case (.Some(let a) where !a, .Some(let b) where b): println("false/nil, true") case (.Some(let a) where a, .Some(let b) where !b): println("true, false/nil")
I want to avoid the following
if let a = self.beaconList["a"] { if let b = self.beaconList["b"] { // a, b } else { // a, !b } } else { if let b = self.beaconList["b"] { // !a, b } else { // !a, !b } }
switch-statement tuples swift optional
nflacco
source share