比方说,您可以使用以下代码:
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)
是的,您可以通过对外部参数名称使用下划线来使参数匿名:
struct SomeStruct { init (_ arg1: String,_ arg2: Int){ // Does Stuff with Variables } }