1.

When is the usage of a set more preferable than an array in ios Swift?

Answer»

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 Swift, such as strings and integers. Hash values are used in sets to look for things QUICKLY.


Discussion

No Comment Found