- Mastering macOS Programming
- Stuart Grimshaw
- 99字
- 2021-07-02 22:54:16
Naming of types and variables
By now, you'll probably have spotted the pattern, but here it is anyway:
TypeNames are written in CapitalizedCamelCase.
We use uncapitalizedCamelCase for variableNames and constantNames.
Swift is pretty relaxed about what characters you use for naming, but there are a few rules:
- Names may not contain whitespace characters
- Names may not contain math symbols, line-drawing characters, or arrows
- Names may not begin with a number (but numbers are fine anywhere else in the name)
- Names may not be the same as Swift keywords (actually, there is a way to do this, but just don't)