Last active
May 22, 2019 12:50
-
-
Save pofat/1b59e8464fa8e4027b78e0d93a62bcb7 to your computer and use it in GitHub Desktop.
Protocol and conformance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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