Syntax

Swift Constant and Variable Syntax

In Swift, constant and variable: let is constant, var can change — let name = "Ada" var count = 0

Quick Answer

Syntax
let name = "Ada" var count = 0
SwiftSyntax

Constant and Variable

Code example
let name = "Ada" var count = 0

let is constant, var can change.

Learn More

How to constant and variable in Swift

  1. Open your Swift file or editor.
  2. Copy the example, then replace its sample names and values for your code.

Swift Constant and Variable Syntax

Use let name = "Ada" var count = 0.

Related Syntax References

Frequently asked questions

What is the Swift syntax for constant and variable?

Use this pattern: let name = "Ada" var count = 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