diff options
Diffstat (limited to 'zh-cn')
| -rw-r--r-- | zh-cn/bf-cn.html.markdown (renamed from zh-cn/brainfuck-cn.html.markdown) | 2 | ||||
| -rw-r--r-- | zh-cn/markdown-cn.html.markdown | 8 | ||||
| -rw-r--r-- | zh-cn/scala-cn.html.markdown | 2 | ||||
| -rw-r--r-- | zh-cn/swift-cn.html.markdown | 43 | 
4 files changed, 24 insertions, 31 deletions
| diff --git a/zh-cn/brainfuck-cn.html.markdown b/zh-cn/bf-cn.html.markdown index a6f3fa09..6cea3012 100644 --- a/zh-cn/brainfuck-cn.html.markdown +++ b/zh-cn/bf-cn.html.markdown @@ -1,5 +1,5 @@  --- -language: brainfuck +language: bf  lang: zh-cn  contributors:      - ["Prajit Ramachandran", "http://prajitr.github.io/"] diff --git a/zh-cn/markdown-cn.html.markdown b/zh-cn/markdown-cn.html.markdown index b633714d..87ed46ad 100644 --- a/zh-cn/markdown-cn.html.markdown +++ b/zh-cn/markdown-cn.html.markdown @@ -53,7 +53,7 @@ __此文本也是__  **_或者这样。_**  *__这个也是!__* -<!-- 在 Github 采用的 Markdown 中 --> +<!-- 在 GitHub 采用的 Markdown 中 -->  ~~此文本为删除线效果。~~ @@ -142,7 +142,7 @@ __此文本也是__  John 甚至不知道 `go_to()` 方程是干嘛的! -<!-- 在Github的 Markdown中,对于代码你可以使用特殊的语法 --> +<!-- 在GitHub的 Markdown中,对于代码你可以使用特殊的语法 -->  \`\`\`ruby <!-- 插入时记得移除反斜线, 仅留```ruby ! -->  def foobar @@ -150,7 +150,7 @@ def foobar  end  \`\`\` <!-- 这里也是,移除反斜线,仅留 ``` --> -<!-- 以上代码不需要缩进,而且 Github 会根据```后表明的语言来进行语法高亮 --> +<!-- 以上代码不需要缩进,而且 GitHub 会根据```后表明的语言来进行语法高亮 -->  <!-- 水平线 (<hr />) -->  <!-- 水平线可由三个或以上的星号或者减号创建,可带可不带空格。 --> @@ -220,7 +220,7 @@ end  斜体化, 所以我就: \*这段置文字于星号之间\*。  <!-- 表格 --> -<!-- 表格只被 Github 的 Markdown 支持,并且有一点笨重,但如果你真的要用的话: --> +<!-- 表格只被 GitHub 的 Markdown 支持,并且有一点笨重,但如果你真的要用的话: -->  | 第一列        | 第二列    | 第三列       |  | :----------   | :------:  | ----------:  | diff --git a/zh-cn/scala-cn.html.markdown b/zh-cn/scala-cn.html.markdown index 508dd58e..f3327b5b 100644 --- a/zh-cn/scala-cn.html.markdown +++ b/zh-cn/scala-cn.html.markdown @@ -369,7 +369,7 @@ object Dog {  // Case 类是有额外内建功能的类。Scala 初学者常遇到的问题之一便是何时用类  // 和何时用 case 类。界线比较模糊,但通常类倾向于封装,多态和行为。类中的值 -// 的作用域一般为 private , 只有方向是暴露的。case 类的主要目的是放置不可变 +// 的作用域一般为 private , 只有方法是暴露的。case 类的主要目的是放置不可变  // 数据。它们通常只有几个方法,且方法几乎没有副作用。  case class Person(name: String, phoneNumber: String) diff --git a/zh-cn/swift-cn.html.markdown b/zh-cn/swift-cn.html.markdown index 3efe4941..017a7812 100644 --- a/zh-cn/swift-cn.html.markdown +++ b/zh-cn/swift-cn.html.markdown @@ -31,7 +31,7 @@ import UIKit  // Swift2.0 println() 及 print() 已经整合成 print()。  print("Hello, world") // 这是原本的 println(),会自动进入下一行 -print("Hello, world", appendNewLine: false) // 如果不要自动进入下一行,需设定进入下一行为 false +print("Hello, world", terminator: "") // 如果不要自动进入下一行,需设定结束符为空串  // 变量 (var) 的值设置后可以随意改变  // 常量 (let) 的值设置后不能改变 @@ -171,8 +171,8 @@ while i < 1000 {      i *= 2  } -// do-while 循环 -do { +// repeat-while 循环 +repeat {      print("hello")  } while 1 == 2 @@ -212,11 +212,11 @@ default: // 在 Swift 里,switch 语句的 case 必须处理所有可能的情  func greet(name: String, day: String) -> String {      return "Hello \(name), today is \(day)."  } -greet("Bob", "Tuesday") +greet("Bob", day: "Tuesday") -// 函数参数前带 `#` 表示外部参数名和内部参数名使用同一个名称。 +// 第一个参数表示外部参数名和内部参数名使用同一个名称。  // 第二个参数表示外部参数名使用 `externalParamName` ,内部参数名使用 `localParamName` -func greet2(#requiredName: String, externalParamName localParamName: String) -> String { +func greet2(requiredName requiredName: String, externalParamName localParamName: String) -> String {      return "Hello \(requiredName), the day is \(localParamName)"  }  greet2(requiredName:"John", externalParamName: "Sunday")    // 调用时,使用命名参数来指定参数的值 @@ -235,8 +235,8 @@ print("Gas price: \(price)")  // 可变参数  func setup(numbers: Int...) {      // 可变参数是个数组 -    let number = numbers[0] -    let argCount = numbers.count +    let _ = numbers[0] +    let _ = numbers.count  }  // 函数变量以及函数作为返回值返回 @@ -257,7 +257,7 @@ func swapTwoInts(inout a: Int, inout b: Int) {  }  var someIntA = 7  var someIntB = 3 -swapTwoInts(&someIntA, &someIntB) +swapTwoInts(&someIntA, b: &someIntB)  print(someIntB) // 7 @@ -286,17 +286,10 @@ numbers = numbers.map({ number in 3 * number })  print(numbers) // [3, 6, 18]  // 简洁的闭包 -numbers = sorted(numbers) { $0 > $1 } -// 函数的最后一个参数可以放在括号之外,上面的语句是这个语句的简写形式 -// numbers = sorted(numbers, { $0 > $1 }) +numbers = numbers.sort { $0 > $1 }  print(numbers) // [18, 6, 3] -// 超级简洁的闭包,因为 `<` 是个操作符函数 -numbers = sorted(numbers, < ) - -print(numbers) // [3, 6, 18] -  //  // MARK: 结构体 @@ -305,7 +298,7 @@ print(numbers) // [3, 6, 18]  // 结构体和类非常类似,可以有属性和方法  struct NamesTable { -    let names = [String]() +    let names: [String]      // 自定义下标运算符      subscript(index: Int) -> String { @@ -516,7 +509,7 @@ protocol ShapeGenerator {  // 一个类实现一个带 optional 方法的协议时,可以实现或不实现这个方法  // optional 方法可以使用 optional 规则来调用  @objc protocol TransformShape { -    optional func reshaped() +    optional func reshape()      optional func canReshape() -> Bool  } @@ -528,9 +521,9 @@ class MyShape: Rect {          // 在 optional 属性,方法或下标运算符后面加一个问号,可以优雅地忽略 nil 值,返回 nil。          // 这样就不会引起运行时错误 (runtime error) -        if let allow = self.delegate?.canReshape?() { +        if let reshape = self.delegate?.canReshape?() where reshape {              // 注意语句中的问号 -            self.delegate?.reshaped?() +            self.delegate?.reshape?()          }      }  } @@ -542,8 +535,8 @@ class MyShape: Rect {  // 扩展: 给一个已经存在的数据类型添加功能 -// 给 Square 类添加 `Printable` 协议的实现,现在其支持 `Printable` 协议 -extension Square: Printable { +// 给 Square 类添加 `CustomStringConvertible` 协议的实现,现在其支持 `CustomStringConvertible` 协议 +extension Square: CustomStringConvertible {      var description: String {          return "Area: \(self.getArea()) - ID: \(self.identifier)"      } @@ -567,8 +560,8 @@ print(14.multiplyBy(3)) // 42  // 泛型: 和 Java 及 C# 的泛型类似,使用 `where` 关键字来限制类型。  // 如果只有一个类型限制,可以省略 `where` 关键字 -func findIndex<T: Equatable>(array: [T], valueToFind: T) -> Int? { -    for (index, value) in enumerate(array) { +func findIndex<T: Equatable>(array: [T], _ valueToFind: T) -> Int? { +    for (index, value) in array.enumerate() {          if value == valueToFind {              return index          } | 
