Comments (3)
估计得跟上面连着一块看,而且要把leftjustify中的left去掉
var alignment = TextAlignment.justify
switch alignment {
case .left:
print("left aligned")
case .right:
print("right aligned")
case .center:
default:
print("center aligned")
}
表示虽然枚举中添加了成员值,虽然把情况全覆盖,但是输出的不是我们想要的值
from turingwechatgroups.
应该跟这句话有关系
如果在枚举中增加了一个成员值但是没有更新switch语句,那么switch语句在遇到新的成员值时会跳到default。代码能编译通过,但不是你想要的结果,正如我们在代码清单14-8中看到的那样。
from turingwechatgroups.
@yangyangnote 确实是的,是书中的错误,多了个left.你可以去图灵《Swift编程权威指南(第2版)》页面提交勘误.
这段代码要表达的意思就是不建议用default分支去判断枚举,而建议使用case列举全部成员变量,这样有助于后期在增减枚举类型成员变量时,更好的维护,不容易出错.
from turingwechatgroups.
Related Issues (5)
- Swift 编程权威指南 第14章 递归枚举问题 HOT 1
- 有微信群号么,怎么参加? HOT 3
- 是不更新了么?
- WeChat ID变更
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from turingwechatgroups.