Syntax
Swift Type Annotation Syntax
In Swift, type annotation: declares a variable's type — var score: Double = 0
Quick Answer
- Syntax
var score: Double = 0
SwiftSyntax
Type Annotation
Code example
var score: Double = 0
Declares a variable's type.
How to type annotation in Swift
- Open your Swift file or editor.
- Copy the example, then replace its sample names and values for your code.
Swift Type Annotation Syntax
Use var score: Double = 0.
Related Syntax References
Frequently asked questions
What is the Swift syntax for type annotation?
Use this pattern: var score: Double = 0
Can I copy this Swift code example?
Yes. Use Copy code and adapt the example to your program.
Is this Swift syntax different on Mac or Windows?
No. The language syntax is the same across operating systems.
Official source · How we verify