Skip to content

Instantly share code, notes, and snippets.

@pofat
Last active May 22, 2019 12:50
Show Gist options
  • Save pofat/1b59e8464fa8e4027b78e0d93a62bcb7 to your computer and use it in GitHub Desktop.
Save pofat/1b59e8464fa8e4027b78e0d93a62bcb7 to your computer and use it in GitHub Desktop.
Protocol and conformance
protocol Drawable {
func draw()
}
struct Point: Drawable {
var x: Int
var y: Int
func draw() {
print("Draw a point at (\(x), \(y))")
}
}
// Main
let point: Drawable = Point(x: 1, y: 1)
point.draw()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment