//---declare a dictionary---
var stocks = Dictionary<String, Double>()
//---populate the dictionary---
stocks["AAPL"] = 109.15
stocks["MSFT"] = 42.97
stocks["GOOG"] = 603.00
//---extract the keys as an array---
let symbols = Array(stocks.keys) //["AAPL", "GOOG", "MSFT"]
//---extract the values as an array---
let prices = Array(stocks.values) //[109.15, 603, 42.97]
No comments:
Post a Comment