Skip to content

Instantly share code, notes, and snippets.

@laevandus
Created September 8, 2023 08:46
Show Gist options
  • Save laevandus/417fd4c6d9ee99fbc0016b8d42d17c3c to your computer and use it in GitHub Desktop.
Save laevandus/417fd4c6d9ee99fbc0016b8d42d17c3c to your computer and use it in GitHub Desktop.
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