-
視頻中設計到剩下的疑問。以后可以回頭再來看查看全部
-
集合-交集查看全部
-
可選類型數據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
提交
取消