Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

import Cocoa

/*var dict1: Dictionary<String, Double> = [:]


var dict2 = Dictionary<String, Double>()
var dict3: [String:Double] = [:]
var dict4 = [String:Double]()*/

var movieRatings = ["Donnie Darko": 4, "Chungking Express":5, "Dark City": 4]

print("I have rated \(movieRatings.count) movies.")


let darkoRating = movieRatings["Donnie Darko"]
movieRatings["Dark City"] = 5
movieRatings

/*let oldRating: Int? = movieRatings.updateValue(5, forKey: "Donnie Darko")


if let lastRating = oldRating, let currentRating = movieRatings["Donnie Darko"] {
print("Old rating: \(lastRating); current rating: \(currentRating)")
}*/

let oldRating: Int? = movieRatings.updateValue(5, forKey: "Donnie Darko1")


if let lastRating = oldRating, let currentRating = movieRatings["Donnie Darko"] {
print("Old rating: \(lastRating); current rating: \(currentRating)")
}

movieRatings["The Cabinet of Dr. Caligari"] = 6


movieRatings.removeValue(forKey: "Dark City")

for (key, value) in movieRatings {


print("The movie \(key) was rated \(value).") }

for movie in movieRatings.keys {


print("User has rated \(movie).") }

var teamPlayers = ["Giants": ["Ryan Reynolds", "Starlight Dancer", "Doug McKnight", "Teddy
Bear", "John Chambers"], "Reds": ["Liz Hernandez", "James Uno", "Doug Uno", "Tom Platner",
"Ashley Walker"], "Angels": ["Mike Uno", "Liana Beicken", "Jan Levinson", "Michael Scott",
"Taylor Brown"]]

print(teamPlayers)

for (_, value) in teamPlayers {


print("\(value)")
}
let players = Array(teamPlayers.values)

print(players)

You might also like