Get immediate access to this and over 1,500+ other videos and books.

Boost your skills with a raywenderlich.com Beginner subscription. With over 60+ video courses and our core foundational programming books bundled in one subscription, it’s simply the best investment you can make in your development career.

Work with Sets

This video was last updated on May 3 2022

Now that you understand sets, you will learn how to really leverage their utility by using several set operations.

Contributors

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a raywenderlich.com Professional subscription.

In the previous episode, you were introduced to the set. You saw that sets have no order and remove duplicates. But I didn’t go into the real power behind behind sets. And that’s comparing sets to other other sets.

var electricCars = { 'Tesla', 'Ford', 'BMW', 'Rivian' };
var gasCars = { 'Ford', 'Ram', 'BMW'};
var allCars = gasCars.union(electricCars);
print(allCars);
var justGasCars = gasCars.difference(electricCars);
print(justGasCars);
var makesGasAndElectricCars = gasCars.intersection(electricCars);
print(makesGasAndElectricCars);

Reviews

Comments