What output will be produced by the code below?

struct Spaceship {
    fileprivate(set) var name = "Serenity"

var serenity = Spaceship() = "Jayne's Chariot"

Correct answer: "Jayne's Chariot".

Explanation: Creating a property using fileprivate(set) means that Swift won't let code from other files modify that property directly. However, Swift playgrounds are compiled into a single file when run, and code that exists in the same file as a fileprivate property can access it directly.



© 2017