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 can actually make your code safe, because you are declaring to the compiler:
Declare this value, and never let it change. Ever.
So a typical example of this might be a
URL that is used for network calls within your application.
let resourceLocation = "https://jsonplaceholder.typicode.com/todos/1"
now trying to change
resourceLocation to any other value, like the following:
resourceLocation = "another location"
reveals a rather nasty error
Cannot assign to value: ‘resourceLocation’ is a ‘let’ constant
Ok. That’s us well told
Constants are much like functions or variables in Swift. Just use any combination of:
However, coding conventions of starting constants with an
Underscore can be confusing in Swift, and are not recommended.
In fact, constants should read as nouns and be in
lowerCamelCase — but of course this is defined by the style guide that you are following for your coding needs.
You want to write code that is easy to read, and clear to understand. Part of this is using
This is important when you have values in your code that you don’t want to change. These
constants have many uses, and prevent your program from acting in unexpected ways and therefore can help provide easily understandable and safe code.
The Twitter contact:
Any questions? You can get in touch with me here