-
视频中设计到剩下的疑问。以后可以回头再来看查看全部
-
集合-交集查看全部
-
可选类型数据if let的解包方式查看全部
-
可选型变量在声明时要显式地声明 var imOptional: String? = "Hello"查看全部
-
func tier1MailFeeBy(weight:Int) -> Int { return 1 * weight } func tier2MailFeeBy(weight:Int) -> Int { return 3 * weight } func chooseMailFeeCalculationBy(weight: Int) -> (Int) -> Int { return weight <= 10 ? tier1MailFeeBy : tier2MailFeeBy } func feeBy(unitPrice: Int, weight: Int) ->Int { let maiFeeByWeight = chooseMailFeeCalculationBy(weight) return maiFeeByWeight(weight) + unitPrice * weight } var price = 20 var weight = 15 feeBy(price, weight: weight)查看全部
-
import UIKit //默认参数 func sayHelloTo(name: String , withGreetingWord greeting: String = "Hello",mpubctuation: String = "!") -> String {<br> return "\(greeting),\(name)\(mpubctuation)" } sayHelloTo("Playground", withGreetingWord: "Hello")<br> sayHelloTo("bobob") sayHelloTo("imooc", mpubctuation: "!!!") //可变参数 func mean(numbers: Double...) -> Double { var sum: Double = 0 for number in numbers { sum += number } return sum / Double(numbers.count) } mean(1,2) mean(12,13,45) func sayHelloTo1(names: String ... , withGreetingWord greeting: String,mpubctuation: String){ for name in names { print("\(greeting), \(name)\(mpubctuation)") } } sayHelloTo1("A","B","C" , withGreetingWord:"Hi" , mpubctuation: "!!")查看全部
-
//一般第一个参数的外部参数名包含在函数名中;withGreetingWord为外部参数名;greeting为内部参数名 func sayHelloTo( name: String , withGreetingWord greeting: String ) -> String { return "\(name),\(greeting)" } //sayHelloTo("Playground", greeting: "Hello") sayHelloTo("Playground", withGreetingWord: "Hello") //计算乘积 func mutipleOf( num1: Int , and num2: Int) -> Int { return num1 * num2 } mutipleOf(4, and: 2) //如果我们只想显示两个值字段 func mutiply( num1: Int , _ num2: Int) -> Int { return num1 * num2 } mutiply(5, 10)查看全部
-
覅查看全部
-
嘿嘿嘿哈哈哈查看全部
-
可选形解包查看全部
-
union并集查看全部
-
" ?? " 可选型能解包就取??前的值,无法解包就取??后的值查看全部
-
集合:去重且无序,数组有序列表查看全部
-
集合的操作查看全部
-
errorMessage?.UppercaseString 不确定errorMessage是否nil的情况下去解包,不为nil的时候调用 UppercaseString 属性。 errorMessage!.UppercaseString 确定errorMessage 不为nil的情况下强制解包,并调用 UppercaseString 属性。查看全部
举报
0/150
提交
取消