Skip to content

Instantly share code, notes, and snippets.

@JudeMolloy
Created September 28, 2017 20:54
Show Gist options
  • Save JudeMolloy/c4abae4363b358bc2e37f2b3f4774369 to your computer and use it in GitHub Desktop.
Save JudeMolloy/c4abae4363b358bc2e37f2b3f4774369 to your computer and use it in GitHub Desktop.
private mutating func performPendingBinaryOperation() {
if pbo != nil && accumulator != nil {
accumulator = pbo!.perform(with: accumulator!)
pbo = nil
}
}
private var pbo: PendingBinaryOperation?
private struct PendingBinaryOperation {
let function: (Double, Double) -> Double
let firstOperand: Double
func perform(with secondOperand: Double) -> Double {
return function(firstOperand, secondOperand)
}
}
mutating func setOperand(_ operand: Double) {
accumulator = operand
}
var result: Double? {
get {
return accumulator
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment