标签:style blog http java color get
本文转自cocoaChina,原文链接:点这里
1 abs(-1) == 1 2 abs(-42) == 42 3 abs(42) == 42
1 var languages = ["Swift", "Objective-C"] 2 contains(languages, "Swift") == true 3 contains(languages, "Java") == false 4 contains([29, 85, 42, 96, 75], 42) == true
var languages = ["Swift", "Objective-C"] var oldLanguages = dropFirst(languages) equal(oldLanguages, ["Objective-C"]) == true
var languages = ["Swift", "Objective-C"] var newLanguages = dropLast(languages) equal(newLanguages, ["Swift"]) == true
1 var languages = ["Swift", "Objective-C"] 2 3 dump(languages) 4 5 // Prints: 6 7 // ? 2 elements 8 9 // - [0]: Swift 10 11 // - [1]: Objective-C
1 var languages = ["Swift", "Objective-C"] 2 3 equal(languages, ["Swift", "Objective-C"]) == true 4 5 var oldLanguages = dropFirst(languages) 6 7 equal(oldLanguages, ["Objective-C"]) == true
1 for i in filter(1...100, { $0 % 10 == 0 }) 2 3 { 4 5 // 10, 20, 30, ... 6 7 println(i) 8 9 assert(contains([10, 20, 30, 40, 50, 60, 70, 80, 90, 100], i)) 10 11 }
1 var languages = ["Swift", "Objective-C"] 2 3 find(languages, "Objective-C") == 1 4 5 find(languages, "Java") == nil 6 7 find([29, 85, 42, 96, 75], 42) == 2
1 equal(indices([29, 85, 42]), [0, 1, 2]) 2 for i in indices([29, 85, 42]) { 3 4 // 0, 1, 2 5 6 println(i) 7 8 }
1 join(":", ["A", "B", "C"]) == "A:B:C" 2 3 var languages = ["Swift", "Objective-C"] 4 5 join("/", languages) == "Swift/Objective-C"
1 equal(map(1...3, { $0 * 5 }), [5, 10, 15]) 2 for i in map(1...10, { $0 * 10 }) { 3 4 // 10, 20, 30, ... 5 6 println(i) 7 8 assert(contains([10, 20, 30, 40, 50, 60, 70, 80, 90, 100], i)) 9 10 }
1 max(0, 1) == 1 2 max(8, 2, 3) == 8
1 maxElement(1...10) == 10 2 var languages = ["Swift", "Objective-C"] 3 4 maxElement(languages) == "Swift"
1 minElement(1...10) == 1 2 var languages = ["Swift", "Objective-C"] 3 4 minElement(languages) == "Objective-C"
1 var languages = ["Swift", "Objective-C"] 2 3 reduce(languages, "", { $0 + $1 }) == "SwiftObjective-C" 4 5 reduce([10, 20, 5], 1, { $0 * $1 }) == 1000
1 equal(reverse([1, 2, 3]), [3, 2, 1]) 2 for i in reverse([1, 2, 3]) { 3 4 // 3, 2, 1 5 6 println(i) 7 8 }
1 startsWith("foobar", "foo") == true 2 3 startsWith(10..100, 10..15) == true 4 5 var languages = ["Swift", "Objective-C"] 6 7 startsWith(languages, ["Swift"]) == true
1 abs(...) 2 advance(...) 3 alignof(...) 4 alignofValue(...) 5 assert(...) 6 bridgeFromObjectiveC(...) 7 bridgeFromObjectiveCUnconditional(...) 8 bridgeToObjectiveC(...) 9 bridgeToObjectiveCUnconditional(...) 10 c_malloc_size(...) 11 c_memcpy(...) 12 c_putchar(...) 13 contains(...) 14 count(...) 15 countElements(...) 16 countLeadingZeros(...) 17 debugPrint(...) 18 debugPrintln(...) 19 distance(...) 20 dropFirst(...) 21 dropLast(...) 22 dump(...) 23 encodeBitsAsWords(...) 24 enumerate(...) 25 equal(...) 26 filter(...) 27 find(...) 28 getBridgedObjectiveCType(...) 29 getVaList(...) 30 indices(...) 31 insertionSort(...) 32 isBridgedToObjectiveC(...) 33 isBridgedVerbatimToObjectiveC(...) 34 isUniquelyReferenced(...) 35 join(...) 36 lexicographicalCompare(...) 37 map(...) 38 max(...) 39 maxElement(...) 40 min(...) 41 minElement(...) 42 numericCast(...) 43 partition(...) 44 posix_read(...) 45 posix_write(...) 46 print(...) 47 println(...) 48 quickSort(...) 49 reduce(...) 50 reflect(...) 51 reinterpretCast(...) 52 reverse(...) 53 roundUpToAlignment(...) 54 sizeof(...) 55 sizeofValue(...) 56 sort(...) 57 split(...) 58 startsWith(...) 59 strideof(...) 60 strideofValue(...) 61 swap(...) 62 swift_MagicMirrorData_summaryImpl(...) 63 swift_bufferAllocate(...) 64 swift_keepAlive(...) 65 toString(...) 66 transcode(...) 67 underestimateCount(...) 68 unsafeReflect(...) 69 withExtendedLifetime(...) 70 withObjectAtPlusZero(...) 71 withUnsafePointer(...) 72 withUnsafePointerToObject(...) 73 withUnsafePointers(...) 74 withVaList(...)
标签:style blog http java color get
原文地址:http://www.cnblogs.com/lizhengfeng/p/3798691.html