Constants in Swift

Keep that value fixed!

Steven Curtis
2 min readFeb 6, 2020

Constants are treated in different ways by programming languages. Swift is no different!

Photo by Lisanto 李奕良 on Unsplash

Difficulty: Beginner | Easy | Normal | Challenging

Prerequisites:

  • Be able to produce a “Hello, World!” iOS application (guide HERE)
  • Naming conventions are touched upon(guide HERE)

Terminology

Character: A character, usually associated with a letter of the alphabet

Constant: A value that can not be amended during the normal execution of a program

Compiler: A program that converts instructions into a machine-code or lower-level form so that they can be read and executed by a computer

lowerCamelCase: A naming convention where the name is formed of multiple words joined as a single word, but the first letter of each word is capitalized. The first letter is in lower case.

Underscore: The _ character, in Swift this generally indicates that a piece of information is missing

URL: Uniform Resource Locator. An address of a web page or resource

Constants

Constants can actually make your code safe, because you are declaring to the compiler:

--

--