From f43cb3fdb97db19bf56a6227974dfc3c4588d992 Mon Sep 17 00:00:00 2001 From: Sunset Wan Date: Sat, 26 Jun 2021 19:52:30 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E7=A4=BA=E4=BE=8B=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=9B=B4=E6=96=B0=20(#1149)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/02_language_guide/22_Generics.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/02_language_guide/22_Generics.md b/source/02_language_guide/22_Generics.md index 091937cf..4b6e4bd3 100644 --- a/source/02_language_guide/22_Generics.md +++ b/source/02_language_guide/22_Generics.md @@ -135,7 +135,7 @@ swapTwoValues(&someString, &anotherString) ```swift struct IntStack { - var items = [Int]() + var items: [Int] = [] mutating func push(_ item: Int) { items.append(item) } @@ -153,7 +153,7 @@ struct IntStack { ```swift struct Stack { - var items = [Element]() + var items: [Element] = [] mutating func push(_ item: Element) { items.append(item) } @@ -354,7 +354,7 @@ protocol Container { ```swift struct IntStack: Container { // IntStack 的原始实现部分 - var items = [Int]() + var items: [Int] = [] mutating func push(_ item: Int) { items.append(item) } @@ -386,7 +386,7 @@ struct IntStack: Container { ```swift struct Stack: Container { // Stack 的原始实现部分 - var items = [Element]() + var items: [Element] = [] mutating func push(_ item: Element) { items.append(item) } @@ -721,7 +721,7 @@ protocol ComparableContainer: Container where Item: Comparable { } extension Container { subscript(indices: Indices) -> [Item] where Indices.Iterator.Element == Int { - var result = [Item]() + var result: [Item] = [] for index in indices { result.append(self[index]) }