I'm using xCode 6.3 and following along with the Stanford Swift programming online (free) class, I typed in the same code as the instructor to implement the square root function.
Yet, although the code (below) looks identical to what works for him, I'm getting a "Method 'performOperation' with Objective-C selector 'performOperation:' conflicts with previous declaration with the same Objective-C selector."
Confusing since the argument lists are clearly different.
Of course this is a swift project and all the swift code has been working up to this point so I'm a bit confused.
Is this a known bug or do I have a syntax issue below which is preventing the simple function overloading to work?
Thanks in advance,
- m
Yet, although the code (below) looks identical to what works for him, I'm getting a "Method 'performOperation' with Objective-C selector 'performOperation:' conflicts with previous declaration with the same Objective-C selector."
Confusing since the argument lists are clearly different.
Of course this is a swift project and all the swift code has been working up to this point so I'm a bit confused.
Is this a known bug or do I have a syntax issue below which is preventing the simple function overloading to work?
Thanks in advance,
- m
Code:
[COLOR="Blue"] func performOperation[B](operation: (Double, Double) -> Double)[/B]
{
if (operandStack.count >= 2)
{
displayValue = operation(operandStack.removeLast(), operandStack.removeLast())
enter()
}
}
// overloaded performOperation for square root which only has one argument.
func performOperation[B](operation: Double -> Double)[/B]
{
if (operandStack.count >= 1)
{
displayValue = operation(operandStack.removeLast())
enter()
}
}[/COLOR]
Last edited by a moderator: