protocol FullyNamed {
    var fullName: String { get }
}


struct Person: FullyNamed {
    var fullName: String
}
let john = Person(fullName: "John Appleseed")
print("\(john.fullName)" )

class Starship: FullyNamed {
    var prefix: String?
    var name: String
    init(name: String, prefix: String? = nil) {
        self.name = name
        self.prefix = prefix
    }
    var fullName: String {
        return (prefix != nil ? prefix! + " " : "") + name
    }
}
var ncc1701 = Starship(name: "Enterprise", prefix: "USS")
 print("\(ncc1701.fullName)" )
 
 protocol RandomNumberGenerator {
    func random() -> Double
}

protocol Togglable {
    mutating func toggle()
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: