Key Concepts

Review core concepts you need to learn to master this subject

Basic Output

print("Hello, world!") // Prints: Hello, world!

print() outputs one or more values to the terminal.

Program Structure

print("Hello, world!") // Prints: Hello, world!

The program runs line by line, from top to bottom:

  • The 1st line prints Hello.
  • The 2nd line prints Hello again.

Single-line Comments

print("Hello, world!") // Prints: Hello, world!

Single-line comments are created using two consecutive forward slashes. The compiler ignores any text after // on the same line.

Multiline Comments

print("Hello, world!") // Prints: Hello, world!

Multiline comments are created using /* to begin the comment, and */ to end the comment. The compiler ignores any text in between.

Hello World
Lesson 1 of 1
  1. 1
    Swift is a powerful and intuitive general-purpose programming language developed by Apple. Its development started in July 2010. Much of the inspiration for Sw…
  2. 2
    Take 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…
  3. 3
    We 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…
  4. 4
    Our 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…
  5. 5
    Woohoo! 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…

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo