-
-
Save laevandus/417fd4c6d9ee99fbc0016b8d42d17c3c to your computer and use it in GitHub Desktop.
This file contains 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
struct Circle { | |
let centre: CGPoint | |
let radius: Double | |
} | |
extension Circle { | |
init(diameter: Double) { | |
centre = . zero | |
radius = diameter / 2 | |
} | |
} | |
// Auto-generated is kept because init is in an extension | |
let circle = Circle(centre: .zero, radius: 3) | |
// Custom | |
let circle2 = Circle(diameter: 6) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment