Learn Swift - Chapter 1: print
If you wanted to display the words Yo, World! on a piece of paper, what is one way you might do that? One way might be to print those words to a piece of paper with a printer or copier.
What if you wanted to print those words on an LCD or other type of screen? In HTML you could do it like this:
In Swift you would do it like this:
print is a keyword - which is a word that has a special meaning in Swift. This keyword means, Print, on the screen, the following message. Did you notice that print is typed all in lowercase? Swift is case sensitive, which is a way of saying that to Swift, the programming language, Print is not the same thing as print. If you were to type this:
you would get an error and it wouldn't work.
The parentheses, (), that encapsulate the quote, "Yo, World!", are a special requirement of Swift. You will get used to seeing them, as you will be typing them many times. If you haven't yet committed to muscle memory location of the 9 and 0 keys on your keyboard, you soon will.
In Swift, the text is between quotation marks like this "Yo, World!", and is called a string. It is a string of characters inside quotes. Another term for this, outside the world of programming, is a quote.
Notice how the opening quotation mark is immediately after the opening parenthesis. There are no spaces between the two. The same goes for the closing quotation mark and closing parenthesis. No spaces there either.
print( "Yo, World!")
or this way.
print("Yo, World!" )
But not this way.
See how the spaces in the last example are after the opening quotation mark? That would render the spaces in the printed message which would make it different than the other examples.