Swift Data Types

In Swift, we need not give explicit types to these variables. They are implicitly inferred from the type of value they were assigned. This is known as Type inference. Type inference allows us to omit the variable type when we define it. The compiler will infer the type, based on the initial value.   For […]

Swift variable and constant

In Swift, Constants and variables must be defined prior to using them.   Variable A variable’s value can be updated to a new value. To define a variable, use the “var” keyword. For example, var num1 = 10 num1 = 20 // no error   Constant Constant values can be assigned only once. To define […]

Swift Playground in Xcode

Playgrounds are interactive work environments in Xcode that let us write code and see the results immediately. To start with a Playground, the first thing we need to do is to start Xcode. Once Xcode has started, we can select the Get started with a playground option, as shown in the following screenshot:     […]