diff --git a/chapter1/01_swift.html b/chapter1/01_swift.html index ea19b7f8..d23b35c5 100644 --- a/chapter1/01_swift.html +++ b/chapter1/01_swift.html @@ -46,7 +46,7 @@ -
Swift 是一种新的编程语言,用于编写 iOS 和 OS X 应用程序。Swift 结合了 C 和 Objective-C 的优点并且不受C的兼容性的限制。Swift 使用安全的编程模式并添加了很多新特性,这将使编程更简单,扩展性更强,也更有趣。除此之外,Swift 还支持人见人爱的 Cocoa 和 Cocoa Touch 框架。拥有了这些特性,Swift将重新定义软件开发。
diff --git a/chapter1/02_a_swift_tour.html b/chapter1/02_a_swift_tour.html index f7c6dff6..0b44f03f 100644 --- a/chapter1/02_a_swift_tour.html +++ b/chapter1/02_a_swift_tour.html @@ -46,7 +46,7 @@ -本页内容包括:
diff --git a/chapter1/chapter1.html b/chapter1/chapter1.html index c7eb0567..501a3b02 100644 --- a/chapter1/chapter1.html +++ b/chapter1/chapter1.html @@ -46,7 +46,7 @@ -在本章中您将了解 Swift 的特性和开发历史,并对 Swift 有一个初步的了解。
diff --git a/chapter2/01_The_Basics.html b/chapter2/01_The_Basics.html index ffa2be9f..993dd38d 100644 --- a/chapter2/01_The_Basics.html +++ b/chapter2/01_The_Basics.html @@ -46,7 +46,7 @@ -Swift 是 iOS 和 OS X 应用开发的一门新语言。然而,如果你有 C 或者 Objective-C 开发经验的话,你会发现 Swift 的很多内容都是你熟悉的。
diff --git a/chapter2/02_Basic_Operators.html b/chapter2/02_Basic_Operators.html index fd0e8625..3228f448 100644 --- a/chapter2/02_Basic_Operators.html +++ b/chapter2/02_Basic_Operators.html @@ -46,7 +46,7 @@ -运算符是检查, 改变, 合并值的特殊符号或短语. 例如, 加号 + 把计算两个数的和(如 let i = 1 + 2). 复杂些的运行算包括逻辑与&&(如 if enteredDoorCode && passedRetinaScan), 还有自增运算符 ++i 这样让自身加一的便捷运算.
本页包含内容:
diff --git a/chapter2/04_Collection_Types.html b/chapter2/04_Collection_Types.html index d0166e81..3f9f9576 100644 --- a/chapter2/04_Collection_Types.html +++ b/chapter2/04_Collection_Types.html @@ -46,7 +46,7 @@ -本页包含内容:
diff --git a/chapter2/07_Closures.html b/chapter2/07_Closures.html index bd21bbe5..251bfb27 100644 --- a/chapter2/07_Closures.html +++ b/chapter2/07_Closures.html @@ -46,7 +46,7 @@ -本页内容包含:
diff --git a/chapter2/08_Enumerations.html b/chapter2/08_Enumerations.html index ff96b70d..95b3c4fd 100644 --- a/chapter2/08_Enumerations.html +++ b/chapter2/08_Enumerations.html @@ -46,7 +46,7 @@ -本页包含内容:
diff --git a/chapter2/10_Properties.html b/chapter2/10_Properties.html index f480ecef..cbc8895d 100644 --- a/chapter2/10_Properties.html +++ b/chapter2/10_Properties.html @@ -46,7 +46,7 @@ -在一个类的实例被释放之前,析构函数被立即调用。用关键字deinit来标示析构函数,类似于初始化函数用init来标示。析构函数只适用于类类型。
+Swift会自动释放不再需要的实例以释放资源。如自动引用计数那一章描述,Swift通过自动引用计数(ARC)处理实例的内存管理。通常当你的实例被释放时不需要手动的去清理。但是,当使用自己的资源时,你可能需要进行一些额外的清理。例如,如果创建了一个自定义的类来打开一个文件,并写入一些数据,你可能需要在类实例被释放之前关闭该文件。
+在类的定义中,每个类最多只能有一个析构函数。析构函数不带任何参数,在写法上不带括号:
+1 deinit {
+2 // 执行析构过程
+3 }
+析构函数是在实例释放发生前一步被自动调用。不允许主动调用自己的析构函数。子类继承了父类的析构函数,并且在子类析构函数实现的最后,父类的析构函数被自动调用。即使子类没有提供自己的析构函数,父类的析构函数也总是被调用。
+因为直到实例的析构函数被调用时,实例才会被释放,所以析构函数可以访问所有请求实例的属性,并且根据那些属性可以修改它的行为(比如查找一个需要被关闭的文件的名称)。
+这里是一个析构函数操作的例子。这个例子是一个简单的游戏,定义了两种新类型,Bank和Player。Bank结构体管理一个虚拟货币的流通,在这个流通中Bank永远不可能拥有超过10,000的硬币。在这个游戏中有且只能有一个Bank存在,因此Bank由带有静态属性和静态方法的结构体实现,从而存储和管理其当前的状态。
+1 struct Bank {
+2 static var coinsInBank = 10_000
+3 static func vendCoins(var numberOfCoinsToVend: Int) -> Int {
+4 numberOfCoinsToVend = min(numberOfCoinsToVend, coinsInBank)
+5 coinsInBank -= numberOfCoinsToVend
+6 return numberOfCoinsToVend
+7 }
+8 static func receiveCoins(coins: Int) {
+9 coinsInBank += coins
+10 }
+11 }
+Bank根据它的coinsInBank属性来跟踪当前它拥有的硬币数量。银行还提供两个方法—vendCoins和receiveCoins,用来处理硬币的分发和收集。
+vendCoins方法在bank分发硬币之前检查是否有足够的硬币。如果没有足够多的硬币,bank返回一个比请求时小的数字(如果没有硬币留在bank中就返回0)。vendCoins方法声明numberOfCoinsToVend为一个变量参数,这样就可以在方法体的内部修改数字,而不需要定义一个新的变量。vendCoins方法返回一个整型值,表明了提供的硬币的实际数目。
+receiveCoins方法只是将bank的硬币存储和接收到的硬币数目相加,再保存回bank。
+Player类描述了游戏中的一个玩家。每一个player在任何时刻都有一定数量的硬币存储在他们的钱包中。这通过player的coinsInPurse属性来体现:
+ 1 class Player {
+ 2 var coinsInPurse: Int
+ 3 init(coins: Int) {
+ 4 coinsInPurse = Bank.vendCoins(coins)
+ 5 }
+ 6 func winCoins(coins: Int) {
+ 7 coinsInPurse += Bank.vendCoins(coins)
+ 8 }
+ 9 deinit {
+ 10 Bank.receiveCoins(coinsInPurse)
+ 11 }
+ 12 }
+每个Player实例都由一个指定数目硬币组成的启动额度初始化,这些硬币在bank初始化的过程中得到。如果没有足够的硬币可用,Player实例可能收到比指定数目少的硬币。
+Player类定义了一个winCoins方法,该方法从bank获取一定数量的硬币,并把它们添加到player的钱包。Player类还实现了一个析构函数,这个析构函数在Player实例释放前一步被调用。这里析构函数只是将player的所有硬币都返回给bank:
+1 var playerOne: Player? = Player(coins: 100)
+2 println("A new player has joined the game with \ (playerOne!.coinsInPurse) coins")
+3 // 输出 "A new player has joined the game with 100 coins"
+4 println("There are now \(Bank.coinsInBank) coins left in the bank")
+5 // 输出 "There are now 9900 coins left in the bank"
+一个新的Player实例随着一个100个硬币(如果有)的请求而被创建。这个Player实例存储在一个名为playerOne的可选Player变量中。这里使用一个可选变量,是因为players可以随时离开游戏。设置为可选使得你可以跟踪当前是否有player在游戏中。
+因为playerOne是可选的,所以由一个感叹号(!)来修饰,每当其winCoins方法被调用时,coinsInPurse属性被访问并打印出它的默认硬币数目。
+1 playerOne!.winCoins(2_000)
+2 println("PlayerOne won 2000 coins & now has \ (playerOne!.coinsInPurse) coins")
+3 // 输出 "PlayerOne won 2000 coins & now has 2100 coins"
+4 println("The bank now only has \(Bank.coinsInBank) coins left")
+5 // 输出 "The bank now only has 7900 coins left"
+这里,player已经赢得了2,000硬币。player的钱包现在有2,100硬币,bank只剩余7,900硬币。
+1 playerOne = nil
+2 println("PlayerOne has left the game")
+3 // 输出 "PlayerOne has left the game"
+4 println("The bank now has \(Bank.coinsInBank) coins")
+5 // 输出 "The bank now has 10000 coins"
+player现在已经离开了游戏。这表明是要将可选的playerOne变量设置为nil,意思是"没有Player实例"。当这种情况发生的时候,playerOne变量对Player实例的引用被破坏了。没有其它属性或者变量引用Player实例,因此为了清空它占用的内存从而释放它。在这发生前一步,其析构函数被自动调用,其硬币被返回到bank。
+ + +本页包含内容:
@@ -608,7 +608,7 @@可选链(Optional Chaining)是一种可以请求和调用属性、方法及子脚本的过程,它的自判断性体现于请求或调用的目标当前可能为空(nil)。如果自判断的目标有值,那么调用就会成功;相反,如果选择的目标为空(nil),则这种调用将返回空(nil)。多次请求或调用可以被链接在一起形成一个链,如果任何一个节点为空(nil)将导致整个链失效。
++笔记: +
+Swift的自判断链和Objective-C中的消息为空有些相像,但是Swift可以使用在任意类型中,并且失败与否可以被检测到。
通过在想调用的属性、方法、或子脚本的自判断值(optional value)(非空)后面放一个问号,可以定义一个可选链。这一点很像在自判断值后面放一个声明符号来强制拆得其封包内的值。他们的主要的区别在于当自判断值为空时可选链即刻失败,然而一般的强制解析将会引发运行时错误。
为了反映可选链可以调用空(nil),不论你调用的属性、方法、子脚本等返回的值是不是自判断值,它的返回结果都是一个自判断值。你可以利用这个返回值来检测你的可选链是否调用成功,有返回值即成功,返回nil则失败。
调用可选链的返回结果与原本的返回结果具有相同的类型,但是原本的返回结果被包装成了一个自判断值,当可选链调用成功时,一个应该返回Int的属性将会返回Int?。
下面几段代码将解释可选链和强制解析的不同。
+首先定义两个类Person和Residence。
class Person {
+var residence: Residence?
+}
+
+class Residence {
+var numberOfRooms = 1
+}
+Residence具有一个Int类型的numberOfRooms,其值为1。Person具有一个自判断residence属性,它的类型是Residence?。
如果你创建一个新的Person实例,它的residence属性由于是被定义为自判断型的,此属性将默认初始化为空:
+let john = Person()
+如果你想使用声明符!强制解析获得这个人residence属性numberOfRooms属性值,将会引发运行时错误,因为这时没有可以供解析的residence值。
let roomCount = john.residence!.numberOfRooms
+// this triggers a runtime error”
+//将导致运行时错误
+当john.residence不是nil时,会运行通过,且会将roomCount 设置为一个int类型的合理值。然而,如上所述,当residence为空时,这个代码将会导致运行时错误。
可选链提供了一种另一种获得numberOfRooms的方法。利用可选链,使用问号来代替原来!的位置:
if let roomCount = john.residence?.numberOfRooms {
+ println("John's residence has \(roomCount) room(s).")
+} else {
+ println("Unable to retrieve the number of rooms.")
+}
+// 打印 "Unable to retrieve the number of rooms.
+这告诉Swift来链接自判断residence?属性,如果residence存在则取回numberOfRooms的值。
因为这种尝试获得numberOfRooms的操作有可能失败,可选链会返回Int?类型值,或者称作“自判断Int”。当residence是空的时候(上例),选择Int将会为空,因此会出先无法访问numberOfRooms的情况。
要注意的是,即使numberOfRooms是非自判断Int(Int?)时这一点也成立。只要是通过可选链的请求就意味着最后numberOfRooms总是返回一个Int?而不是Int。
你可以自己定义一个Residence实例给john.residence,这样它就不再为空了:
john.residence = Residence()
+john.residence 现在有了实际存在的实例而不是nil了。如果你想使用和前面一样的可选链来获得numberOfRoooms,它将返回一个包含默认值1的Int?:
if let roomCount = john.residence?.numberOfRooms {
+println("John's residence has \(roomCount) room(s).")
+} else {
+ println("Unable to retrieve the number of rooms.")
+}
+// 打印 "John's residence has 1 room(s)"。
+你可以使用可选链来多层调用属性,方法,和子脚本。这让你可以利用它们之间的复杂模型来获取更底层的属性,并检查是否可以成功获取此类底层属性。
+后面的代码定义了四个将在后面使用的模型类,其中包括多层可选链。这些类是由上面的Person和Residence模型通过添加一个Room和一个Address类拓展来。
Person类定义与之前相同。
class Person {
+var residence: Residence?
+}
+Residence类比之前复杂些。这次,它定义了一个变量 rooms,它被初始化为一个Room[]类型的空数组:
class Residence {
+ var rooms = Room[]()
+ var numberOfRooms: Int {
+ return rooms.count
+ }
+ subscript(i: Int) -> Room {
+ return rooms[i]
+ }
+ func printNumberOfRooms() {
+ println("The number of rooms is \(numberOfRooms)")
+ }
+ var address: Address?
+}
+因为Residence存储了一个Room实例的数组,它的numberOfRooms属性值不是一个固定的存储值,而是通过计算而来的。numberOfRooms属性值是由返回rooms数组的count属性值得到的。
为了能快速访问rooms数组,Residence定义了一个只读的子脚本,通过插入数组的元素角标就可以成功调用。如果该角标存在,子脚本则将该元素返回。
Residence中也提供了一个printNumberOfRooms的方法,即简单的打印房间个数。
最后,Residence定义了一个自判断属性叫address(address?)。Address类的属性将在后面定义。
+用于rooms数组的Room类是一个很简单的类,它只有一个name属性和一个设定room名的初始化器。
class Room {
+ let name: String
+ init(name: String) { self.name = name }
+}
+这个模型中的最终类叫做Address。它有三个自判断属性他们额类型是String?。前面两个自判断属性buildingName和 buildingNumber作为地址的一部分,是定义某个建筑物的两种方式。第三个属性street,用于命名地址的街道名:
class Address {
+ var buildingName: String?
+ var buildingNumber: String?
+ var street: String?
+ func buildingIdentifier() -> String? {
+ if buildingName {
+ return buildingName
+ } else if buildingNumber {
+ return buildingNumber
+ } else {
+ return nil
+ }
+ }
+}
+Address类还提供了一个buildingIdentifier的方法,它的返回值类型为String?。这个方法检查buildingName和buildingNumber的属性,如果buildingName有值则将其返回,或者如果buildingNumber有值则将其返回,再或如果没有一个属性有值,返回空。
正如上面“ 可选链可替代强制解析”中所述,你可以利用可选链的自判断值获取属性,并且检查属性是否获取成功。然而,你不能使用可选链为属性赋值。
+使用上述定义的类来创建一个人实例,并再次尝试后去它的numberOfRooms属性:
let john = Person()
+if let roomCount = john.residence?.numberOfRooms {
+ println("John's residence has \(roomCount) room(s).")
+} else {
+ println("Unable to retrieve the number of rooms.")
+}
+// 打印 "Unable to retrieve the number of rooms。
+由于john.residence是空,所以这个可选链和之前一样失败了,但是没有运行时错误。
你可以使用可选链的来调用自判断值的方法并检查方法调用是否成功。即使这个方法没有返回值,你依然可以使用可选链来达成这一目的。
+Residence的printNumberOfRooms方法会打印numberOfRooms的当前值。方法如下:
+func printNumberOfRooms(){
+ println(“The number of rooms is \(numberOfRooms)”)
+}
+这个方法没有返回值。但是,没有返回值类型的函数和方法有一个隐式的返回值类型Void(参见Function Without Return Values)。
如果你利用可选链调用此方法,这个方法的返回值类型将是Void?,而不是Void,因为当通过可选链调用方法时返回值总是自判断类型(optional type)。,即使是这个方法本是没有定义返回值,你也可以使用if语句来检查是否能成功调用printNumberOfRooms方法:如果方法通过可选链调用成功,printNumberOfRooms的隐式返回值将会是Void,如果没有成功,将返回nil:
if john.residence?.printNumberOfRooms() {
+ println("It was possible to print the number of rooms.")
+} else {
+ println("It was not possible to print the number of rooms.")
+}
+// 打印 "It was not possible to print the number of rooms."。
+你可以使用可选链来尝试从子脚本获取值并检查子脚本的调用是否成功,然而,你不能通过可选链来设置子代码。
+++注意: +当你使用可选链来获取子脚本的时候,你应该将问号放在子脚本括号的前面而不是后面。可选链的问号一般直接跟在自判断表达语句的后面。
+
下面这个例子用在Residence类中定义的子脚本来获取john.residence数组中第一个房间的名字。因为john.residence现在是nil,子脚本的调用失败了。
if let firstRoomName = john.residence?[0].name {
+ println("The first room name is \(firstRoomName).")
+} else {
+ println("Unable to retrieve the first room name.")
+}
+// 打印 "Unable to retrieve the first room name."。
+在子代码调用中可选链的问号直接跟在john.residence的后面,在子脚本括号的前面,因为john.residence是可选链试图获得的自判断值。
如果你创建一个Residence实例给john.residence,且在他的rooms数组中有一个或多个Room实例,那么你可以使用可选链通过Residence子脚本来获取在rooms数组中的实例了:
let johnsHouse = Residence()
+johnsHouse.rooms += Room(name: "Living Room")
+johnsHouse.rooms += Room(name: "Kitchen")
+john.residence = johnsHouse
+
+if let firstRoomName = john.residence?[0].name {
+ println("The first room name is \(firstRoomName).")
+} else {
+ println("Unable to retrieve the first room name.")
+}
+// 打印 "The first room name is Living Room."。
+你可以将多层可选链连接在一起,可以掘取模型内更下层的属性方法和子脚本。然而多层可选链不能再添加比已经返回的自判断值更多的层。 +也就是说:
+如果你试图获得的类型不是自判断类型,由于使用了可选链它将变成自判断类型。 +如果你试图获得的类型已经是自判断类型,由于可选链它也不会提高自判断性。
+因此:
+如果你试图通过可选链获得Int值,不论使用了多少层链接返回的总是Int?。
+相似的,如果你试图通过可选链获得Int?值,不论使用了多少层链接返回的总是Int?。
下面的例子试图获取john的residence属性里的address的street属性。这里使用了两层可选链来联系residence和address属性,他们两者都是自判断类型:
if let johnsStreet = john.residence?.address?.street {
+ println("John's street name is \(johnsStreet).")
+} else {
+ println("Unable to retrieve the address.")
+}
+// 打印 "Unable to retrieve the address.”。
+john.residence的值现在包含一个Residence实例,然而john.residence.address现在是nil,因此john.residence?.address?.street调用失败。
从上面的例子发现,你试图获得street属性值。这个属性的类型是String?。因此尽管在自判断类型属性前使用了两层可选链,john.residence?.address?.street的返回值类型也是String?。
如果你为Address设定一个实例来作为john.residence.address的值,并为address的street属性设定一个实际值,你可以通过多层可选链来得到这个属性值。
let johnsAddress = Address()
+johnsAddress.buildingName = "The Larches"
+johnsAddress.street = "Laurel Street"
+john.residence!.address = johnsAddress
+
+if let johnsStreet = john.residence?.address?.street {
+ println("John's street name is \(johnsStreet).")
+} else {
+ println("Unable to retrieve the address.")
+}
+// 打印 "John's street name is Laurel Street."。
+值得注意的是,“!”符的在定义address实例时的使用(john.residence.address)。john.residence属性是一个自判断类型,因此你需要在它获取address属性之前使用!解析以获得它的实际值。
前面的例子解释了如何通过可选链来获得自判断类型属性值。你也可以通过调用返回自判断类型值的方法并按需链接方法的返回值。
+下面的例子通过可选链调用了Address类中的buildingIdentifier 方法。这个方法的返回值类型是String?。如上所述,这个方法在可选链调用后最终的返回值类型依然是String?:
if let buildingIdentifier = john.residence?.address?.buildingIdentifier() {
+ println("John's building identifier is \(buildingIdentifier).")
+}
+// 打印 "John's building identifier is The Larches."。
+如果你还想进一步对方法返回值执行可选链,将可选链问号符放在方法括号的后面:
+if let upper = john.residence?.address?.buildingIdentifier()?.uppercaseString {
+ println("John's uppercase building identifier is \(upper).")
+}
+// 打印 "John's uppercase building identifier is THE LARCHES."。
+++ + +注意: +在上面的例子中,你将可选链问号符放在括号后面是因为你想要链接的自判断值是
+buildingIdentifier方法的返回值,不是buildingIdentifier方法本身。
(ps:为了方便各位检验所以保留了英文,可删。) diff --git a/chapter2/19_Nested_Types.html b/chapter2/19_Nested_Types.html index 547759d3..a384b293 100644 --- a/chapter2/19_Nested_Types.html +++ b/chapter2/19_Nested_Types.html @@ -46,7 +46,7 @@ -
本页包含内容:
diff --git a/chapter2/20_Extensions.html b/chapter2/20_Extensions.html index 3f9c6b3b..73b917d7 100644 --- a/chapter2/20_Extensions.html +++ b/chapter2/20_Extensions.html @@ -46,7 +46,7 @@ -本章介绍了 Swift 的各种特性及其使用方法,是全书的核心部分。
diff --git a/chapter3/01_About_the_Language_Reference.html b/chapter3/01_About_the_Language_Reference.html index e0c3fa85..df5796cb 100644 --- a/chapter3/01_About_the_Language_Reference.html +++ b/chapter3/01_About_the_Language_Reference.html @@ -46,7 +46,7 @@ -本书的这一节描述了Swift编程语言的形式语法。这里描述的语法是为了帮助您更详细的了解该语言,而不是让您直接实现一个解析器或编译器。
diff --git a/chapter3/02_Lexical_Structure.html b/chapter3/02_Lexical_Structure.html index 72806f86..c1f17ac2 100644 --- a/chapter3/02_Lexical_Structure.html +++ b/chapter3/02_Lexical_Structure.html @@ -46,7 +46,7 @@ -Swift 是苹果在 WWDC 2014 上发布的一款全新的编程语言,本书译自苹果官方的 Swift 教程《The Swift Programming Language》。
diff --git a/manifest.appcache b/manifest.appcache index d047bf20..a55256b3 100644 --- a/manifest.appcache +++ b/manifest.appcache @@ -1,5 +1,5 @@ CACHE MANIFEST -# Revision 1402189909809 +# Revision 1402202224393 CACHE: index.html @@ -15,14 +15,14 @@ chapter2/06_Functions.html chapter2/07_Closures.html chapter2/08_Enumerations.html chapter2/09_Classes_and_Structures.html +chapter2/10_Properties.html chapter2/11_Methods.html chapter2/12_Subscripts.html chapter2/02_Basic_Operators.html -chapter2/10_Properties.html chapter2/14_Initialization.html chapter2/15_Deinitialization.html -chapter2/17_Optional_Chaining.html chapter2/16_Automatic_Reference_Counting.html +chapter2/17_Optional_Chaining.html chapter2/18_Type_Casting.html chapter2/19_Nested_Types.html chapter2/20_Extensions.html diff --git a/search_index.json b/search_index.json index e4b721c6..f38c4d05 100644 --- a/search_index.json +++ b/search_index.json @@ -1 +1 @@ -{"version":"0.5.2","fields":[{"name":"title","boost":10},{"name":"body","boost":1}],"ref":"url","documentStore":{"store":{"index.html#gitbook_594":["2014","issu","languag","program","pull","qq群:364279588","request","swift","undefinedundefin","wwdc"],"chapter1/01_swift.html#gitbook_595":["arc","automat","c","cocoa","cocoa的基础上构建框架栈并将其标准化。objective-c","count","c的兼容性的限制。swift","foundat","hello","io","objective-c","os","refer","swift","touch","undefinedundefin","world","x"],"chapter1/02_a_swift_tour.html#gitbook_596":["0","0..3","0..time","0.0","1","10","100","103","11","12","13","16","19","2","2.5","20","25","3","3.0","3.1","3.59","3.69","3.79","4","42","43","5","5.2","50","597","69105","7","7.simpledescript","70","70.0","75","8","87","8:09","9","9.9","94","a.adjust","a.simpledescript","ac","ace.toraw","acerawvalu","add","addon","addone(numb","adescript","adjust","amount","anoth","anotherproperti","ant","anycommonel","anycommonelements([1","appl","applese","applesummari","area","b","b.adjust","b.simpledescript","bdescript","blue","bool","bottl","c","captain","card","card(rank","card添加一个方法,创建一副完整的扑克牌并把每张牌的rank和suit","case","catfish","celeri","chees","class","club","condit","condition(item","convertedrank","convertedrank.simpledescript","count","counter","counter.incrementby(2","cucumb","dai","default","deinit","diamond","dictionary