Swift 1.2 redeclares Objective-C method

前端 未结 3 1566
青春惊慌失措
青春惊慌失措 2021-02-20 11:29

I just updated from swift 1.1 to swift 1.2 and get compiler Error:

Method \'setVacation\' redeclares Objective-C method \'setVacation:\'

Here

3条回答
  •  醉酒成梦
    2021-02-20 12:00

    Cappy: For the Standford problem I used simply this, because it looks like the Xcode Beta simply says that the operation: (Double, Double) -> Double is the same as operation: Double -> Double, I don't know if it is a bug or not...

    But the code below works, but is NOT clean :(

    func performOperation(r:String? = "2", operation: (Double, Double) -> Double) {
        if operandStack.count >= 2 {
            displayValue = operation(operandStack.removeLast(), operandStack.removeLast())
            enter()
        }
    }
    
    func performOperation(operation: Double -> Double) {
        if operandStack.count >= 1 {
            displayValue = operation(operandStack.removeLast())
            enter()
        }
    }
    

提交回复
热议问题