- 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)
推薦閱讀
- 公有云容器化指南:騰訊云TKE實(shí)戰(zhàn)與應(yīng)用
- 程序員修煉之道:從小工到專家
- Google Visualization API Essentials
- 信息系統(tǒng)與數(shù)據(jù)科學(xué)
- 大數(shù)據(jù)導(dǎo)論
- 數(shù)據(jù)庫系統(tǒng)原理及應(yīng)用教程(第4版)
- 大話Oracle Grid:云時(shí)代的RAC
- Python金融實(shí)戰(zhàn)
- MATLAB Graphics and Data Visualization Cookbook
- 重復(fù)數(shù)據(jù)刪除技術(shù):面向大數(shù)據(jù)管理的縮減技術(shù)
- 數(shù)據(jù)修復(fù)技術(shù)與典型實(shí)例實(shí)戰(zhàn)詳解(第2版)
- SQL Server 2008寶典(第2版)
- Python 3爬蟲、數(shù)據(jù)清洗與可視化實(shí)戰(zhàn)
- 區(qū)塊鏈應(yīng)用開發(fā)指南:業(yè)務(wù)場(chǎng)景剖析與實(shí)戰(zhàn)
- 成功之路:ORACLE 11g學(xué)習(xí)筆記