What does this print?
protocol Named {
var name: String { get }
}
struct Item: Named {
var name: String
}
let obj: Named = Item(name: "Box")
print(obj.name)
Try it in the online Swift Playground →
[spoiler title="Solution"]
Answer:
Box
Explanation:
Protocols define requirements; structs can conform and be used as protocol types.
[/spoiler]