xLsDg

Xiao Lu Software Development Group

  1. 生成新的 SSH 秘钥(记得输入 passphrase 口令):

    1
    2
    3
    $ ssh-keygen -t rsa -C "YOUR_EMAIL@YOUREMAIL.COM" -f ~/.ssh/github_rsa
    $ ssh-keygen -t rsa -C "YOUR_EMAIL@YOUREMAIL.COM" -f ~/.ssh/gitcafe_rsa
    $ ssh-keygen -t rsa -C "YOUR_EMAIL@YOUREMAIL.COM" -f ~/.ssh/oschina_rsa
    阅读全文 »

闭包表达式

闭包表达式语法:

1
2
3
4
5
6
7
8
9
10
11
12
let names = ["Chris", "Alex", "Ewa", "Barry", "Daniella"]

func backwards(s1: String, s2: String) -> Bool {
return s1 > s2
}

var reversed = sorted(names, backwards)
// reversed is equal to ["Ewa", "Daniella", "Chris", "Barry", "Alex"]

reversed = sorted(names, { (s1: String, s2: String) -> Bool in
return s1 > s2
})
阅读全文 »

数组

创建空的数组:

1
2
3
var someInts = [Int]()
println("someInts is of type [Int] with \(someInts.count) items.")
// prints "someInts is of type [Int] with 0 items."

添加数组数据项:

1
2
3
4
someInts.append(3)
// someInts now contains 1 value of type Int
someInts = []
// someInts is now an empty array, but is still of type [Int]
阅读全文 »

常量和变量

用let来声明常量,用var来声明变量:

1
2
let maximumNumberOfLoginAttempts = 10
var currentLoginAttempt = 0

类型标注:

1
2
var welcomeMessage: String = "Hello"
var red, green, blue: Double

输出常量和变量:

1
2
var friendlyWelcome = "Hello!"
println("The current value of friendlyWelcome is \(friendlyWelcome)")
阅读全文 »
0%