I am recently venture myself into Swift but I could not understand why my codes does not work when im returning an Int in a method.
protocol StrategyProtocol
{
func calculate(num1:Int, num2:Int) ->Int
}
class Context
{
var _strategyProtocol: StrategyProtocol!
init(_strategyProtocol: StrategyProtocol)
{
self._strategyProtocol=_strategyProtocol
}
func Calculate(num1: Int, num2: Int) ->Int
{
return _strategyProtocol.calculate(num1, num2)
}
}
class Add: StrategyProtocol
{
func calculate(num1: Int, num2: Int) -> Int
{
return num1 + num2
}
}
class Minus: StrategyProtocol
{
func calculate(num1: Int, num2: Int) -> Int
{
return num1 - num2
}
}
apparently this line of code does not work and prompt out missing argument label 'num2:' in call
//return _strategyProtocol.calculate(num1, num2)
can anyone show me how to fix it and explain to me.
Aucun commentaire:
Enregistrer un commentaire