What is the purpose of having two different names for the same parameter?
source link: https://www.codesd.com/item/what-is-the-purpose-of-having-two-different-names-for-the-same-parameter.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
What is the purpose of having two different names for the same parameter?
func mapEachElement (inArray arr: [Int], withFunc aFunc: (Int))
Why would there be "inArray and then "arr"...what's the point?
Same for "withFunc and "aFunc", it makes it more code complicated and also messier to read, why are they even used?
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.
Related Articles
Clustering: two different values for the sum of the squares
How to overload the ++ operator in two different ways for postfix a ++ and prefix ++ a?
What is the second parameter of NSLocalizedString ()?
Use two different cushions for two different browsers
Same method with two different names?
How can you add two different sizes for two different fonts
Two different formats for different numbers
Is it possible to have different names for an app on the Android market and on the phone?
Decoration on the ViewModel property to use a different name for the link
What is the toString parameter?
What is a more succinct way to link the same parameter, multiple times, via pdo
Visual Studio 2010 C # & ldquo; already defined a member with the same parameter type error. & Quot;
Require a parameter name to avoid ambiguity on the same parameter list
Correct method for passing multiple values for the same parameter name in the GET request
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK