Skip to main content

Command Palette

Search for a command to run...

Swift Basics: Introduction

Updated
•2 min read•View as Markdown
Swift Basics: Introduction
M
learning code, one day at a time

Swift is a programming language used to build software for servers, mobile and desktop devices. It also is the language used to build apps for iOS, iPadOS, macOS, watchOS, tvOS and even the most recent visionOS devices.

Swift can be installed on macOs, Linux and Windows although it is required to use Xcode to build for Apple technologies and Xcode can only run on macOS.

As a tradition in any new programming language, let's print our first line of code "Hello, world!" in Swift. This can be done using just a single line of code.

print("Hello, World!") //prints "Hello, World 
//simple,yeah?😁

It is important to note that Swift is a type-safe language which means it is sensitive to the type of data/value you assign to it and would flag it as an error when you assign it to a different data type other than that which it was being assigned to at initialization. This prevents you from running into errors when changing the values of variables. Take a look at the code below:

var age = 21 //this type of value is called an Integer
age = "twenty one" //this type of value is called a String

//the above code would be flagged as an error as you are trying to change the value of the variable "afrom an Integer to a String

It's fine if you're just starting out at Swift and don't understand the above statement, you would as you advance through this series with me😊.

Next, we'd look at look at Variables and Constants.