Swi Interview Questions
20. When is the usage of a set more preferable than an array in
ios Swi ?
If all of the following conditions are met, you should use a set rather than an array:
You only want to add each item once. Duplicates are never permitted in sets.
The order of the items in the collection is irrelevant to you.
You are storing Hashable types, either your own or those provided by Swi , such
as strings and integers. Hash values are used in sets to look for things quickly.
21. Show the use of "self" in a method using an example.
In Swi , the self property of an instance is a special property that holds the instance
itself. In most cases, self appears in a class, structure, or enumeration's initializer or
method. The most common use of self is in initializers when you are likely to want
parameter names that match your type's property names, such as this:
Page 20
© Copyright by Interviewbit