0% found this document useful (0 votes)
4 views2 pages

Swift Bucket List Management Code

This document defines and manipulates bucket list and to-do list arrays in Swift. It creates a bucket list array, adds and removes items, updates items, compares it to another list, and accesses items by index. It also creates a to-do list, makes a copy by iterating backwards, assigns the copy back, shuffles the list, and checks if it is empty.

Uploaded by

casper russell
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Swift Bucket List Management Code

This document defines and manipulates bucket list and to-do list arrays in Swift. It creates a bucket list array, adds and removes items, updates items, compares it to another list, and accesses items by index. It also creates a to-do list, makes a copy by iterating backwards, assigns the copy back, shuffles the list, and checks if it is empty.

Uploaded by

casper russell
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

import Cocoa

var str = "Hello, playground"

var bucketList: Array<String>

var bucketList1 = ["Climb mt. everest"]


/*[Link]("Fly hot air balloon to Fiji")
[Link]("Watch the Lord of the Rings trilogy in one day")
[Link]("Go on a walkabout")
[Link]("Scuba dive in the Great Blue Hole")
[Link]("Find a triple rainbow")*/
var newItems = [
"Fly hot air balloon to Fiji",
"Watch the Lord of the Rings trilogy in one day", "Go on a walkabout",
"Scuba dive in the Great Blue Hole",
"Find a triple rainbow"
]
/*for item in newItems {
[Link](item)
}*/
bucketList1 += newItems
[Link](at: 2)
bucketList1

print([Link])
print(bucketList1[...])

bucketList1[2] += " in Australia"


bucketList1[0] = "Climb Mt. Kilimanjaro"
[Link]("Toboggan across Alaska", at: 2)
bucketList1

var myronsList = [
"Climb Mt. Kilimanjaro",
"Fly hot air balloon to Fiji", "Toboggan across Alaska",
"Go on a walkabout in Australia",
"Scuba dive in the Great Blue Hole", "Find a triple rainbow"
]
let equal = (bucketList1 == myronsList)

let newIndex = [Link](of: "Fly hot air balloon to Fiji")!


let secondIndex = [Link](newIndex, offsetBy: 2)
print(bucketList1[secondIndex])

//[Link]()
print(bucketList1[...])

var toDoList = ["Take out garbage", "Pay bills", "Cross off finished items"]
[Link]

var toDoListCopy: Array<String> = []


for i in 1 ... [Link] {
[Link](toDoList[[Link] - i])
}

print("\n")
print(toDoListCopy)

toDoList = toDoListCopy
print(toDoList)

[Link]()
print(toDoList)

You might also like