上QQ阅读APP看书,第一时间看更新
Anonymous arguments
For some functions, the requirement to use an argument name at the call site can either produce somewhat ungainly--looking code, or can be made superfluous by the name of the function itself. In such cases, we can precede the argument name in the method declaration with an underscore, indicating to the compiler that the argument's name will not be included when calling the function:
func triple(_ a: Int) -> Int
{
return a * 3
}
This code can now be called as follows:
let oldStockPrice = 134
let x = triple(oldStockPrice )