iOS Swift Basics An Introduction to Swift Programming Conventions and Rules

What is White Space characters in Swift /Programming ?

I don't understand what is white space character in Swift /Programming ? Does this rule only apply when declaring variables and constants. Or does this also apply when writing statements ? I seem to be confusing this with inputting spacebar before declaration.

Kenan Bateman
Kenan Bateman
13,122 Points

White space is another word for a spacebar. It's not directly linked to how you use it, just any space is considered "white space"

2 Answers

Kirby Ziada
Kirby Ziada
9,885 Points

Programming languages often don't read spaces.

Hence why; var programmingLanguage="Swift" is also the same as; var programmingLanuage = "Swift"

Or you could have 8 different spaces if you'd like... doesn't matter but it's about being readable for you or anyone else working on the app.

Cahue Beltrao
PRO
Cahue Beltrao
Pro Student 902 Points

In your code, it's mostly for readability and is ignored when being interpreted by a machine, but some programming languages do use whitespaces in some occasions. Also whitespace is not ignored when contained within a variable of type string, then it's a character just like any other.