- Hands-On Design Patterns with Swift
- Florent Vilmart Giordano Scalzo Sergio De Simone
- 71字
- 2021-07-02 14:45:00
Conformance at declaration
The first method to declare a conformance is to do it at the top level, when you declare your custom type. You'll notice that the raw representation comes first, then the protocol conformance:
enum State: Int, Toggling {
case off = 0
case on
mutating func toggle() {
self = self == .on ? .off : .on
}
}
var state: State = .on
state.toggle()
assert(state == .off)
推薦閱讀
- 計(jì)算機(jī)組成原理與接口技術(shù):基于MIPS架構(gòu)實(shí)驗(yàn)教程(第2版)
- Hands-On Data Structures and Algorithms with Rust
- 企業(yè)數(shù)字化創(chuàng)新引擎:企業(yè)級(jí)PaaS平臺(tái)HZERO
- Greenplum:從大數(shù)據(jù)戰(zhàn)略到實(shí)現(xiàn)
- 大數(shù)據(jù)算法
- 大話Oracle Grid:云時(shí)代的RAC
- Hadoop 3.x大數(shù)據(jù)開(kāi)發(fā)實(shí)戰(zhàn)
- Learning Proxmox VE
- 跨領(lǐng)域信息交換方法與技術(shù)(第二版)
- 計(jì)算機(jī)視覺(jué)
- 大數(shù)據(jù)與機(jī)器學(xué)習(xí):實(shí)踐方法與行業(yè)案例
- 實(shí)現(xiàn)領(lǐng)域驅(qū)動(dòng)設(shè)計(jì)
- 企業(yè)大數(shù)據(jù)處理:Spark、Druid、Flume與Kafka應(yīng)用實(shí)踐
- 離線和實(shí)時(shí)大數(shù)據(jù)開(kāi)發(fā)實(shí)戰(zhàn)
- Oracle 11g數(shù)據(jù)庫(kù)管理與開(kāi)發(fā)基礎(chǔ)教程