A Hello World is a simple program that prints
Hello, World! on the screen. This program is often used to introduce a new programming language to beginners.
Let's explore how to create "Hello, World!" program in Swift.
Swift "Hello, World!" Program
// Swift "Hello, World!" Program print("Hello, World!")
Note: If you want to run this program on your computer, make sure that Swift is properly installed. To learn more about setting up Swift on your computer, visit Getting Started with Swift.
How Swift "Hello, World!" Program Works?
Here are the different sections of the Hello World program in Swift:
1. Swift Comment
// Swift "Hello, World!" Program
We use two slashes
// to write comments in Swift.
Comments are hints that we can add to our program to make our code more understandable. They are meant for people reading the code. To learn more, visit Swift Comments.
2. print Statement
The code above displays the text
Hello, World! on your screen.
Congratulations! You just wrote your first program in Swift.
Next we'll learn about variables, constants, and literals in Swift.