上QQ阅读APP看书,第一时间看更新
Implementing required properties
The implementation of protocol properties looks just the same as any other property declaration:
struct MarketingGuy: TalkativePerson
{
let name: String
var address: String
func sayHi() {
print("Yes, I'm \(name), here's my card. Say, may I blah
blah blah...")
}
}
The compiler will help you with two things here:
- It will not let you declare a { get set } property with let
- It will insist that the properties (just like the methods) are implemented