比方说,您可以使用以下代码:
struct SomeStruct { init (arg1: String,arg2: Int){ // Does Stuff with Variables } } // Some Point Later var str = "fasfsad" var integer = 343 let smth = SomeStruct(arg1: str,arg2: integer)
let smth = SomeStruct(str,integer)
是的,您可以通过对外部参数名称使用下划线来使参数匿名:
原文链接:https://www.f2er.com/swift/319123.htmlstruct SomeStruct { init (_ arg1: String,_ arg2: Int){ // Does Stuff with Variables } }