在方法中可以个一些参数设置默认值,在调用该方法的时候,有默认值的参数可以不传递参数
func sayHello1(str1: String = "Hello", str2: String, str3: String = "Wold"){
}
//public func NSLocalizedString(_ key: String,
// tableName: String? = default,
// bundle: Bundle = default,
// value: String = default,
// comment: String) -> String
NSLocalizedString("", tableName: "", bundle: Bundle.main, value: "", comment: "")
// 这个方法的声明含有两个自动关闭类型的参数,类型为 ()->Bool, ()->String 省略为 Bool, String
// 并且 一个含有 default 的默认值,这个默认值会在编译时确定,可以不用我们自己赋值
//public func assert(_ condition: @autoclosure () -> Bool,
// _ message: @autoclosure () -> String = default,
// file: StaticString = #file,
// line: UInt = #line)
//
//assert(3 > 2, "")
sayHello1(str1: "", str2: "")
网友评论