Data update

This commit is contained in:
Ingy döt Net 2024-03-06 22:25:12 -08:00
parent ed705008a8
commit 0df55f9f24
2196 changed files with 32999 additions and 3075 deletions

View file

@ -0,0 +1,33 @@
protocol Pet {
var name: String { get set }
var favouriteToy: String { get set }
func feed() -> Bool
func stroke() -> Void
}
extension Pet {
// Default implementation must be in an extension, not in the declaration above
func stroke() {
print("default purr")
}
}
struct Dog: Pet {
var name: String
var favouriteToy: String
// Required implementation
func feed() -> Bool {
print("more please")
return false
}
// If this were not implemented, the default from the extension above
// would be called.
func stroke() {
print("roll over")
}
}