Skip to content

Instantly share code, notes, and snippets.

@laevandus
Created January 9, 2023 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laevandus/d5412dc4d98fc56d20f77e01d9d8d717 to your computer and use it in GitHub Desktop.
Save laevandus/d5412dc4d98fc56d20f77e01d9d8d717 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