Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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
16,715 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,886 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
PLUS
Cahue Beltrao
Courses Plus 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.