Q:

Joined boolean optimizations Swift

Is there a better way to write this if-statement, which has ultimately four outcomes among three variables?
I looked into guard and switch but I'm not sure if either of those capture the joined boolean states well?  I could individually list the four outcomes as joined boolean statements (eg, isPartialResult == true && calculated == nil, so on..) but that isn't necessarily more readable or efficient (more to type). Thanks!
case .BinaryOperation(let function):
            if isPartialResult == true {
                if calculated == nil {
                    log += (" \(accumulator) \(symbol)")        // add new op
                } else {
                    log += (" \(symbol)")                       // add symbol to calculated, prepare for new op
                    calculated = nil
                }
            } else {
                if log.characters.count <= 1 {
                    log += (" \(accumulator) \(symbol)")        // start from beginning
                } else {
                    log += (" \(symbol)")                       // restart from equal
                }
            }
            executePendingBinaryOperation()
            pending = pendingBinaryOperationInfo(binaryFunction: function, firstOperand: accumulator)
            isPartialResult = true

A:

Given 3 values
let isPartialResult = true
let calculated: String?
let log = "hello"

You can use a switch this way
switch (isPartialResult, calculated, log.characters.count) {
case (true, nil, _): break
case (true, let _, _): break
case (false, _, 0...1): break
case (false, _, 2...Int.max): break
default: fatalError()
}

Now just replace each of the 4 breaks with your outcome.

