Swift Programming – Introduction

Swift is the new programming language used for the iOS, macOS, watchOS and tvOS application development. Swift provides Int for Integers, Double and Float for floating-point values, Bool for Boolean values and String for textual data. Swift also provides three primary collection types, Array, Set and Dictionary.

Swift stores variables and uses its identifying name as reference to values. You may declare a variable with a value as changeable or not. Variables which are non-changeable are known as Constants in Swift.

Swift introduces an advanced type known as tuple, which allows you to group values together. It can be used to return multiple values from a function as a single compound value.

Swift also introduces an optional type to handle the absence of a value. Use of an optional type means either “a value is available” or “no value is available”. Optionals work for any type.

Swift is a type-safe language, which means that if your code requires a String, type safety will not allow you to pass an Int by mistake.