买不起苹果电脑,周六利用公司资源学习ios开放,先从swift基本开始
import Foundation var a = 1 a = 10 var b = 2 b = 6 let c = a + b var str = "hello word" var string:String = "liaojianguo " str = str + string str = "\(str),dabendan,\(100)" str = "\(str)\(c)" var i = 8 var icope:Int = 9 var arr = ["jiaojianguo","dabendan",40,20.98] var arry=[Int]() //var arr4 = String[]() var arr3 = [String](); arr3.append("appliao"); arr3.append("jianguo") arr3.append(" dabendan") //arr3+="zhulongf" arr3+=["haha","heihei"] print(arr3) arr3.insert("000",atIndex:2) print(arr3) for begin in arr3 { print("item : \(begin)") } arr3.removeAtIndex(2); print(arr3) arr3.removeLast() print(arr3) arr3.removeFirst() print(arr3) arr3.removeAll() print("\(arr3) is ?") var diction = Dictionary<String,String>() var dicti:Dictionary<String,String> = ["name":"zhulongf","age":"32"] print(dicti) var someInts2:[Int] = [10,20,30] var arr2:[Int] = [9,10,12] typealias newName = Int var haha:newName = 100 print("=======================") var dict = ["name":"liaojianguo","age":"16"] for di in dict{ print(di) } for (key,value) in dict{ //print("key=" + key + ",value=" + value) print("\(key)=\(value)") } print("=======================") dict["hight"]="171" print(dict) print(dict["name"]) arr3 = [String]() arr3 = ["liaojianguo","zhulongfeng"] var arr7 = [String](count : 4,repeatedValue : "today") print(arr7) var arr8 = arr3 + arr7 print(arr8) print("=======================") var count = 0 while count < arr8.count { print(arr8[count]) count++ } print("=======================") for ind in 0...10{ print(ind) } func sayHello(name:String)-> String{ print("\(name)") return "xixi:" + name } var fun = sayHello fun("hahhahahhahahahahah") var strin = sayHello("liaojianguo") print(strin) func halfOpenRangeLength(start:Int,end:Int)->Int{ return end - start } print(halfOpenRangeLength(7,end : 10)) func getNume()->(a:Int,b:Int) { return (2,3) } let total = getNume() print(total.a) func sum(input:Int...)->Int{ return input.reduce(0,combine: +) } print(sum(1,2,3,4,5,6)) print(getNume())