Skip to content

Instantly share code, notes, and snippets.

@TheMuellenator
Last active July 15, 2024 18:17
Show Gist options
  • Save TheMuellenator/febd64195828e681985a0746f0908f92 to your computer and use it in GitHub Desktop.
Save TheMuellenator/febd64195828e681985a0746f0908f92 to your computer and use it in GitHub Desktop.
iOS repl.it - Dictionaries Challenge Solution
//Don't change this
var stockTickers: [String: String] = ["APPL" : "Apple Inc", "HOG": "Harley-Davidson Inc", "BOOM": "Dynamic Materials", "HEINY": "Heineken", "BEN": "Franklin Resources Inc"]
//Write your code here.
stockTickers["WORK"] = "Slack Technologies Inc"
stockTickers["BOOM"] = "DMC Global Inc"
//Don't modify this
print(stockTickers["WORK"]!)
print(stockTickers["BOOM"]!)
@Magdalenaspace
Copy link

func exercise() {

//Don't change this
var stockTickers: [String: String] = [
    "APPL" : "Apple Inc",
    "HOG": "Harley-Davidson Inc",
    "BOOM": "Dynamic Materials",
    "HEINY": "Heineken",
    "BEN": "Franklin Resources Inc"]

  func updateMyTickers() {
    stockTickers["WORK"] = "Slack Technologies Inc"
    stockTickers.updateValue("DMC Global Inc", forKey: "BOOM")
 //Don't modify this
}
updateMyTickers()
print(stockTickers["WORK"]!)
print(stockTickers["BOOM"]!)

@Magdalenaspace
Copy link

var stockTickers: [String: String] = [
"APPL" : "Apple Inc",
"HOG": "Harley-Davidson Inc",
"BOOM": "Dynamic Materials",
"HEINY": "Heineken",
"BEN": "Franklin Resources Inc"
]

func ubdateMyTickers(){
stockTickers["WORK"] = "Slack Technologies Inc"
stockTickers["BOOM"] = "DMC Global Inc"
}

ubdateMyTickers()

print(stockTickers["WORK"]!)
print(stockTickers["BOOM"]!)

@danieljaw
Copy link

var stockTickers: [String: String] = [
"APPL" : "Apple Inc",
"HOG": "Harley-Davidson Inc",
"BOOM": "Dynamic Materials",
"HEINY": "Heineken",
"BEN": "Franklin Resources Inc"
]

stockTickers["WORK"] = "Slack Technologies Inc"
stockTickers["BOOM"] = "DMC Global Inc"

print(stockTickers["WORK"]!)
print(stockTickers["BOOM"]!)

// I wanted to see how the full dictionary looks like
print(stockTickers)

@alexnavter
Copy link

func exercise() {

    var stockTickers: [String: String] = [
        "APPL" : "Apple Inc",
        "HOG": "Harley-Davidson Inc",
        "BOOM": "Dynamic Materials",
        "HEINY": "Heineken",
        "BEN": "Franklin Resources Inc",
    ]
    
    //Write your code here.
    stockTickers["WORK"] = "Slack Technologies Inc"
    stockTickers["BOOM"] = "DMC Global Inc"
    
     //Don't modify this
    print(stockTickers["WORK"]!)
    print(stockTickers["BOOM"]!)
}

exercise()

@BunyaminMete
Copy link

func exercise() {

//Don't change this
var stockTickers: [String: String] = [
    "APPL" : "Apple Inc", 
	"HOG": "Harley-Davidson Inc", 
	"BOOM": "Dynamic Materials", 
	"HEINY": "Heineken", 
	"BEN": "Franklin Resources Inc"
]

//Write your code here.

stockTickers["WORK"] = "Slack Technologies Inc"
stockTickers["BOOM"] = "DMC Global Inc"

 //Don't modify this
print(stockTickers["WORK"]!)
print(stockTickers["BOOM"]!)

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment