struct CalculatorBrain {
private var accumulator: Double?
func changeSign(operand: Double) -> Double {
return -operand
}
private enum Operation {
case constant(Double)
case unaryOperation((Double) -> Double)
}
private var operations: Dictionary<String,Operation> = [
"π" : Operation.constant(Double.pi),
"√" : Operation.unaryOperation(sqrt),
"±" : Operation.unaryOperation(changeSign) /* Cannot convert value of type '(CalculatorBrain) -> (Double) -> Double' to expected argument type '(Double) -> Double' */
]
}
I am getting the error message on the line starting with "±". I looked up a solution online and here are the similar questions & potential solutions I found below. But I don't quite understand what's going on. Can anyone help?