Complete the code to create an empty array of integers.
var numbers: [Int] = [1]The correct way to create an empty array is with square brackets [].
Complete the code to add a new key-value pair to the dictionary.
var capitals = ["France": "Paris"] capitals["Japan"] = [1]
Dictionary values must be strings in quotes. "Tokyo" is the correct string literal.
Fix the error in the code to create a set of strings.
let fruits: Set<String> = [1]To create a set with values, use Set([...]) with an array inside.
Fill both blanks to create a dictionary comprehension that filters keys with values greater than 10.
let scores = ["Alice": 12, "Bob": 8, "Eve": 15] let filtered = scores.filter { $0.value [1] [2] }
The filter checks if the value is greater than 10 using > 10.
Fill all three blanks to create a dictionary from an array filtering words longer than 4 characters.
let words = ["apple", "dog", "banana", "cat"] let dict = Dictionary(uniqueKeysWithValues: words.filter { $0.count [1] [2] }.map { [3] in ([3], [3].count) })
The filter uses > 4 to select words longer than 4 letters. The map uses 'word' as the key.
