Set vs Array

The main difference is that NSArray is an ordered collection and NSSet is an unordered list of unique elements.

Set
  • Primarily access items by comparison   
E.g    let ingredients = [“Tea Powder”, “Sugar”, “Hot Water”, “Milk”, "Cardamom"]
          if ingredients.contains(“Cardamom”) {
print(“It is Cardamom Tea”)
}
  • unordered
  • does not allow duplicates
Array

  • Can access items by Index
  • Ordered
  • Allow duplicates

3 comments:

  1. Awesome article I really impress it’s very informative and useful.Thanks

    Custom Software Development Australia

    ReplyDelete
  2. Great post with unique information.This blog will really helpful for me to develop my skills in a right way.Thanks for sharing,keep update with your blogs.

    Website Design Company in Bangalore | Mobile App Development Companies in Bangalore | Website Development Company in Bangalore

    ReplyDelete
  3. I appreciate this piece of useful information. CourseDrill academy one of the best leading Training Institute, provides the best Online services with expert Team. For more information visit our site:
    Oracle Fusion HCM Training
    Workday Training
    Okta Training
    Palo Alto Training
    Adobe Analytics Training

    ReplyDelete