Created
January 9, 2023 17:06
-
-
Save laevandus/d5412dc4d98fc56d20f77e01d9d8d717 to your computer and use it in GitHub Desktop.
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
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