What is the point of having two different names for the same parameter?

后端 未结 3 1278
情深已故
情深已故 2020-11-30 14:50
func mapEachElement (inArray arr: [Int],  withFunc aFunc: (Int))

Why would there be \"inArray and then \"arr\"...what\'s the point?

Same f

3条回答
  •  -上瘾入骨i
    2020-11-30 15:30

    inArray is external name which the caller of the function should use when passing parameters. arr is the internal name which the function implementer uses in the implementation to refer to the parameter. You don't have to supply external name.It makes it more readable. It is more like to make swift function names and parameters readable as Objective-C functions are.

提交回复
热议问题