Mastering macOS Programming
上QQ阅读APP看书,第一时间看更新

Replacing classes

We have seen that enum types can be powerful and useful constructs, and in many cases they will replace classes as the go-to data structure. Where value-passing semantics are needed instead of reference passing, and where no inheritance is needed, it's always worth considering whether an enum is, in fact, all that is needed.