Complete the code to print a welcome message in Swift.
print([1])
In Swift, text must be inside double quotes to be a string. So, "Hello, Swift!" is correct.
Complete the code to declare a constant named 'platform' with value 'Apple'.
let [1] = "Apple"
We want the constant named exactly platform as stated.
Fix the error in the function that returns a greeting message.
func greet() -> String {
return [1]
}The function must return a string value. The string needs quotes. So "Hello Swift" is correct.
Fill both blanks to create a dictionary of Apple platforms and their release years.
let platforms = ["iOS": [1], "macOS": [2]]
iOS was released in 2007 and macOS in 2001.
Fill all three blanks to create a filtered dictionary of platforms released after 2005.
let recentPlatforms = Dictionary(uniqueKeysWithValues: platforms.filter { ([1], [2]) in [3] > 2005 })We destructure each dictionary entry into platform (key) and year (value) in the filter closure parameters, then filter where year > 2005. Dictionary(uniqueKeysWithValues:) reconstructs the dictionary from the filtered (key, value) pairs.