第12月第26天 swift 下劃線

1.html

 


The _ is used to define that the parameter is not namedswift

If you have multiple _ it states that you do not need to name the parameters in your function callide

func myFunc(name:String, _ age:String){
}this

myFunc(「Milo", "I'm a really old wizard")
If you do not use the underscore you would usespa

myFunc(「Milo」, age: "I'm a really old wizard")
The _ is not necessary in function calls. It is just used to indicate that something does not to have a name.htm

In regards to how you would refer to your function, You would not have to pass any name for the function call.
But since you also don’t define a parameter type this seems to me like a invalid example (it at least doesn’t work in xCode 7 with swift 2.0)blog

Edit:
Since swift 3.0ip

myFunc(name: 「Milo」, age: "I'm a really old wizard")
Should be usedunderscore

 

http://www.cnblogs.com/bhlsheji/p/4746072.htmlit

https://stackoverflow.com/questions/30876068/what-is-in-swift-telling-me

 

2.

// Set up the quad vertices with respect to the orientation and aspect ratio of the video.

CGRect vertexSamplingRect = AVMakeRectWithAspectRatioInsideRect(self.presentationRect, self.layer.bounds);

相關文章
相關標籤/搜索