print() outputs one or more values to the terminal.
The program runs line by line, from top to bottom:
- The 1st line prints
- The 2nd line prints
Single-line comments are created using two consecutive forward slashes. The compiler ignores any text after
// on the same line.
Multiline comments are created using
/* to begin the comment, and
*/ to end the comment. The compiler ignores any text in between.
- 1Swift is a powerful and intuitive general-purpose programming language developed by Apple. Its development started in July 2010. Much of the inspiration for Sw…
- 2Take a look at the Hello.swift file in the code editor that is placed in the middle of the screen. It’s a Swift program! When learning a new language, tradition suggests that our first program…
- 3We learned how to output a line of text with the following code: print(“”) It will output: We can also output multiple lines by adding more print() statements: print(“Hello”) print(“Go…
- 4Our own code can quickly become difficult to understand when we return to it — sometimes only a few hours later! For this reason, it’s often useful to leave a note or reminder in our code for our f…
- 5Woohoo! You have written a few Swift programs. In this lesson, you have learned: - Swift is a general-purpose coding language. - The code is read from top to bottom. - print() is used to output…