-
視頻中設(shè)計(jì)到剩下的疑問(wèn)。以后可以回頭再來(lái)看查看全部
-
集合-交集查看全部
-
可選類型數(shù)據(jù)if let的解包方式查看全部
-
可選型變量在聲明時(shí)要顯式地聲明 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 //默認(rèn)參數(shù) 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: "!!!") //可變參數(shù) 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: "!!")查看全部
-
//一般第一個(gè)參數(shù)的外部參數(shù)名包含在函數(shù)名中;withGreetingWord為外部參數(shù)名;greeting為內(nèi)部參數(shù)名 func sayHelloTo( name: String , withGreetingWord greeting: String ) -> String { ?? return "\(name),\(greeting)" } //sayHelloTo("Playground", greeting: "Hello") ? sayHelloTo("Playground", withGreetingWord: "Hello") //計(jì)算乘積 func mutipleOf( num1: Int , and num2: Int) -> Int { ?? return num1 * num2 } mutipleOf(4, and: 2) //如果我們只想顯示兩個(gè)值字段 func mutiply( num1: Int , _ num2: Int) -> Int { ?? return num1 * num2 } mutiply(5, 10)查看全部
-
覅查看全部
-
嘿嘿嘿哈哈哈查看全部
-
可選形解包查看全部
-
union并集查看全部
-
" ?? " 可選型能解包就取??前的值,無(wú)法解包就取??后的值查看全部
-
集合:去重且無(wú)序,數(shù)組有序列表查看全部
-
集合的操作查看全部
-
errorMessage?.UppercaseString 不確定errorMessage是否nil的情況下去解包,不為nil的時(shí)候調(diào)用 UppercaseString 屬性。 errorMessage!.UppercaseString 確定errorMessage 不為nil的情況下強(qiáng)制解包,并調(diào)用 UppercaseString 屬性。查看全部
舉報(bào)
0/150
提交
取消