public let cards = [
("🂡", 11), ("🂢", 2), ("🂣", 3), ("🂤", 4), ("🂥", 5), ("🂦", 6), ("🂧", 7), ("🂨", 8), ("🂩", 9), ("🂪", 10), ("🂫", 10), ("🂭", 10), ("🂮", 10),
("🂱", 11), ("🂲", 2), ("🂳", 3), ("🂴", 4), ("🂵", 5), ("🂶", 6), ("🂷", 7), ("🂸", 8), ("🂹", 9), ("🂺", 10), ("🂻", 10), ("🂽", 10), ("🂾", 10),
("🃁", 11), ("🃂", 2), ("🃃", 3), ("🃄", 4), ("🃅", 5), ("🃆", 6), ("🃇", 7), ("🃈", 8), ("🃉", 9), ("🃊", 10), ("🃋", 10), ("🃍", 10), ("🃎", 10),
("🃑", 11), ("🃒", 2), ("🃓", 3), ("🃔", 4), ("🃕", 5), ("🃖", 6), ("🃗", 7), ("🃘", 8), ("🃙", 9), ("🃚", 10), ("🃛", 10), ("🃝", 10), ("🃞", 10)
]
public typealias Card = (String, Int)
public typealias Hand = [Card]
// ⭐️ typealias 竟然可以有 extension ‼️
// 這相當於對 Array<Element> where Element == Card 做 conditional conformance
public extension Hand {
var cardString: String { return map { $0.0 }.joined() }
var points : Int { return map { $0.1 }.reduce(0, +) }
}
// Q: typealias 可以 conform to protocols 嗎❓
// A: 答案是不行。
/*
compiler warning
----------------
conformance of 'Array<Element>' to protocol 'CustomStringConvertible'
conflicts with that stated in the type's module 'Swift' and will be ignored;
there cannot be more than one conformance, even with different conditional bounds.
*/
extension Hand: CustomStringConvertible {
public var description : String { return self.string }
}