Forums
Learn
Careers
Store
About
SUBSCRIBE
UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>
Question 1/6: Which of these are valid in Swift?
Hint: Arrays and dictionaries can be made in two different ways, for example [Int] or Array<Int> both create arrays. Click to show.
[Int]
Array<Int>
Option 1:
var favoriteColors = Dictionary<String, String>()
This code is valid Swift.
Option 2:
var measurements = [Double]
When creating a new empty array you must place empty parentheses after the type, e.g. [Double]().
[Double]()
Correct!
Oops – that's not correct.
Return to Review Menu
You are not logged in
Link copied to your pasteboard.