]> Zhao Yanbai Git Server - acecode.git/commitdiff
...
authoracevest <zhaoyanbai@126.com>
Mon, 12 Jan 2015 02:43:06 +0000 (10:43 +0800)
committeracevest <zhaoyanbai@126.com>
Mon, 12 Jan 2015 02:43:06 +0000 (10:43 +0800)
learn/go/hello/array.go
learn/go/hello/struct.1.go [moved from learn/go/hello/struct.go with 100% similarity]
learn/go/hello/switch.1.go [moved from learn/go/hello/switch.go with 100% similarity]
learn/swift/MyPlayground.playground/contents.xcplayground [new file with mode: 0644]
learn/swift/MyPlayground.playground/section-1.swift [new file with mode: 0644]
learn/swift/MyPlayground.playground/timeline.xctimeline [new file with mode: 0644]

index 11e984193903f037a88edaf72bd21d0c524b6c6a..ef03af91df7c693b5b40dd1338b661e2cbd1d77b 100644 (file)
@@ -26,4 +26,8 @@ func main() {
        for i := 0; i < len(e); i++ {
                fmt.Println(e[i])
        }
+
+       for i, v := range d {
+               fmt.Println(i, v)
+       }
 }
diff --git a/learn/swift/MyPlayground.playground/contents.xcplayground b/learn/swift/MyPlayground.playground/contents.xcplayground
new file mode 100644 (file)
index 0000000..8e39341
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<playground version='3.0' sdk='iphonesimulator'>
+    <sections>
+        <code source-file-name='section-1.swift'/>
+    </sections>
+    <timeline fileName='timeline.xctimeline'/>
+</playground>
\ No newline at end of file
diff --git a/learn/swift/MyPlayground.playground/section-1.swift b/learn/swift/MyPlayground.playground/section-1.swift
new file mode 100644 (file)
index 0000000..56326af
--- /dev/null
@@ -0,0 +1,66 @@
+// Playground - noun: a place where people can play
+
+import UIKit
+
+var str = "Hello, playground"
+println(str)
+
+let Constant = 0x1234   // let 声明常量
+var Variable = 0xAFEC   // var 声明变量
+var VarInt   = 8421
+var VarFloat = 3.1415926
+var VarDouble:Double = 2.71828182846    //如果初始类型信息不足,可以在变量后加":类型"
+var VarF:Float = 0.1314
+
+
+let s = str + String(Variable)  // 类型必需显示转换
+
+
+// 可以通过在客串中加\()的方式把值转换成字符串
+let Int2Str = "translate int in string with \(VarInt) \(str)"
+println(Int2Str)
+
+
+// 数组
+var arrayList = ["apple", "microsoft", "xx", "google", "tencent", "twitter"]
+arrayList[2] = "amazon"
+println(arrayList)
+
+// 字典
+var dict = [
+    "apple" : "USA",
+    "tencnet" : "CN"
+]
+println(dict)
+
+
+// 创建空数组和空字典
+var EmptyArray = [String]()
+var EmptyDict  = [String:String]()
+// or
+var EmptArrayWithNoType = []
+var EmptDictWithNoType = [:]
+
+for cp in arrayList {
+    println(cp)
+}
+
+
+
+var OptionalVar: String? = "hehe"
+OptionalVar == nil
+if let name = OptionalVar {
+    println("Hello \(OptionalVar)")
+}
+else
+{
+    println("sssssss")
+}
+
+
+let word = "red apple"
+
+switch word {
+case "dd" :
+}
+
diff --git a/learn/swift/MyPlayground.playground/timeline.xctimeline b/learn/swift/MyPlayground.playground/timeline.xctimeline
new file mode 100644 (file)
index 0000000..bf468af
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Timeline
+   version = "3.0">
+   <TimelineItems>
+   </TimelineItems>
+</Timeline>