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.

Operate on a List

This video was last updated on Apr 26 2022

See how to manipulate lists with their built-in methods.

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.

So you’ve learned how to create lists, and how to append elements to them, using the append method and the += operator.

const pastries = ['cookie', 'cupcake', 'donut', 'pie'];
print(pastries[0]);
print(pastries[100]);
var morePastries = pastries.sublist(1, 3);
print(morePastries);
morePastries.clear();
print(evenmMorePastries);
print(evenMorePastries.isEmpty);
print(pastries[0]);
print(pastries.first);
print(pastries.last);
print(pastries.length);
print(pastries.contains('cookie'));
print(pastries.contains('lasagna'));
var pastries = ['cookie', 'cupcake', 'donut', 'pie'];
pastries.add('brownie');
print(pastries);
pastries[4] = 'cream puff';
pastries.insert(1, 'tart');
print(pastries);
var pastry = pastries.removeAt(0);
print(pastry);

Reviews

Comments