Swift
abnerwang_smile
主力博客http://abnerwang.github.io/
展开
-
Swift 笔记(十)
我的主力博客:半亩方塘 Dictionaries 1、A dictionary is an unordered collection of pairs, where each pair is comprised of a keyand a value. The same key can’t appear twice in a dictionary, but differen原创 2016-03-03 11:22:31 · 614 阅读 · 0 评论 -
Swift 笔记(八)
我的主力博客:半亩方塘 Arrays 1、You can declare an array either explicitly or taking advantage of Swift's type inference. Here's an example of an explicit declaration: let numbers: Array Sw原创 2016-02-27 16:08:29 · 481 阅读 · 0 评论 -
Swift 笔记(七)
我的主力博客:半亩方塘 Optionals 1、Optionals are Swift's solution to the problem of representing both a value and the absence of a value. An optional type is allowed to reference either a val原创 2016-02-27 15:47:45 · 447 阅读 · 0 评论 -
Swift 笔记(六)
我的主力博客:半亩方塘 Closures 1、Closures are functions without names. Here's a declaration for a varible that can hold a closure: var mutiplyClosure: (Int, Int) -> Int You assign a closure原创 2016-02-27 15:41:23 · 601 阅读 · 0 评论 -
Swift 笔记(五)
我的主力博客:半亩方塘 Functions 1、With two parameters, the function can print out a multiple of any two values. You could achieve this like so: func printMultipleOf(multiplier: Int, andValu原创 2016-02-27 15:30:18 · 451 阅读 · 0 评论 -
Swift 笔记(四)
我的主力博客:半亩方塘 Making Decisions 1、Consider this code: let number = 10 switch (number) { case let x where x % 2 == 0: print("Even") default: print("Odd") } This will pri原创 2016-02-27 15:22:36 · 455 阅读 · 0 评论 -
Swift笔记(一)
我的主力博客:半亩方塘 1、In Swift, you can optionally use underscores to make larger numbers more human-readable. The quantity and placement of the underscores is up to you. var variableNumber: Int = 1_0原创 2016-01-12 21:39:35 · 653 阅读 · 0 评论 -
Swift 笔记(三)
Strings It's possible to add characters to a string. However, Swift's strictness with types means you have to be explicit when doing so, just as you have to be when you work with numbers if one is原创 2016-02-27 15:07:58 · 698 阅读 · 0 评论 -
Swift 笔记(二)
我的主力博客:半亩方塘 Numeric Types & Operations 1、In Swift, you can even use the modulo operate with fractional numbers, like so: let moduloDecimal = 11.6 % 1.2 In this case, modu原创 2016-02-27 15:01:16 · 456 阅读 · 0 评论 -
Swift 笔记(九)
我的主力博客:半亩方塘 Randomizing an array The function below returns a random number between 0 and the given argument: import Foundation func randomFromZeroTo(number: Int) -> Int { return原创 2016-02-29 18:41:23 · 588 阅读 · 0 评论