Explain Enum in Swift

Enum is also known as Swift Enumeration. Enum is a data type which contains a set of the related values. It is declared in a class and its values are accessed through the instance members of that class. In Swift, an enum, short for enumeration, is a user-defined data type that enables you to define … Read more

What are functions in Swift?

Functions are the set of codes used to perform specific task. In Swift programming language, functions are used to pass local as well global parameter values inside the function’s call. In Swift4, functions can be categorized in two types: User Defined Functions Built-in Functions (Library Functions) In Swift, functions are self-contained blocks of code that … Read more

What are the Half Open Range operators in Swift?

Swift supports several types of operators. One of them is Half Open Range operator. The half open range operator specifies a range between two values a and b (a<b) where b is not included. It is known as half open range operator because it contains its first value only not the final value. In Swift, … Read more

How can you make a property optional in Swift?

We have to declare a question mark ??’ in the code to make a property optional. If a property doesn’t have a value, then the symbol ? helps to avoid the runtime error. In Swift, you can make a property optional by declaring it with a question mark ? after its type. This indicates that … Read more

What is the meaning of question mark “?” in Swift?

In Swift, question mark “?” is used in property declaration. It tells the compiler that this property is optional. The property may hold a value or not. It avoids runtime errors when accessing that property by using ?. This is useful in optional chaining and a variant of this example is in conditional clauses. For … Read more