Skip to content

Instantly share code, notes, and snippets.

@lucianoschillagi
Created September 2, 2024 23:54
Show Gist options
  • Save lucianoschillagi/a8cfcfc7bdeeb1478fb159cec47115bf to your computer and use it in GitHub Desktop.
Save lucianoschillagi/a8cfcfc7bdeeb1478fb159cec47115bf to your computer and use it in GitHub Desktop.
Custom Implementations with Protocol Extensions
import Foundation
protocol Greetable {
var name: String { get }
func greet()
}
extension Greetable {
func greet() {
print("Hello, \(name)")
}
}
struct Person: Greetable {
var name: String
}
let person = Person(name: "Juan")
person.greet()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment