Why does a function call require the parameter name in Swift?

后端 未结 6 1213
夕颜
夕颜 2020-11-27 10:42

I have this Function in a class:

func multiply(factor1:Int, factor2:Int) -> Int{
    return factor1 * factor2
}

I try to call the functi

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-27 11:18

    A note about passing in a method as an argument that returns no value:

    func refresh(obj:Obj, _ method: (Obj)->Void = setValue) {
        method(element)
    }
    func setValue(obj:Obj){
        obj.value = "someValue"
    }
    refresh(someObj,setValue)
    

提交回复
热议问题