Swift: Adding and inserting items to a list

This entry is part 25 of 41 in the series Swift

Adding and inserting items to a list

var list = ["David", "Derek", "Dragon"];

print("Total no of members: \(list.count)\n");

list += ["Emily", "Evan"];
list.insert("Amy", atIndex:0);

var item:String;

for item in list {
    print(item);
}

swift

Series Navigation<< Swift Operators
Swift: Swapping of 2 variables >>

Leave a comment

Leave a Reply