Tuple has named elements title, author, year. To swap title and author, assign them in a tuple swap.
Step 2: Check syntax for swapping
var book = (title: "Swift Guide", author: "John Appleseed", year: 2023)
(book.title, book.author) = (book.author, book.title) correctly declares named tuple and swaps title and author using tuple assignment.
Step 3: Analyze other options
var book = ("Swift Guide", "John Appleseed", 2023)
(book.title, book.author) = (book.author, book.title) lacks names, so title and author don't exist as properties. var book = (title: "Swift Guide", author: "John Appleseed", year: 2023)
book = (book.author, book.title, book.year) changes order but loses names. var book = (title: "Swift Guide", author: "John Appleseed", year: 2023)
book.swap(title, author) uses invalid swap method.
Final Answer:
var book = (title: "Swift Guide", author: "John Appleseed", year: 2023)
(book.title, book.author) = (book.author, book.title) -> Option A
Quick Check:
Swap named tuple elements with tuple assignment [OK]
Quick Trick:Swap tuple elements by assigning a tuple of swapped values [OK]
Common Mistakes:
Trying to swap unnamed tuple elements
Using invalid methods like .swap()
Reassigning tuple without names
Master "Data Types" in Swift
9 interactive learning modes - each teaches the same concept differently