Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit ed4646a

Browse files
author
Kerr Marin Miller
committed
Remove example definition
1 parent 2023733 commit ed4646a

File tree

1 file changed

+0
-49
lines changed

1 file changed

+0
-49
lines changed

swift/README.md

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -340,55 +340,6 @@ Classes have [reference semantics](https://developer.apple.com/library/mac/docum
340340

341341
Sometimes, things should be structs but need to conform to `AnyObject` or are historically modeled as classes already (`NSDate`, `NSSet`). Try to follow these guidelines as closely as possible.
342342

343-
### Example definition
344-
345-
Here's an example of a well-styled class definition:
346-
347-
```swift
348-
class Circle: Shape {
349-
var x: Int
350-
var y: Int
351-
var radius: Double
352-
var diameter: Double {
353-
get {
354-
return radius * 2
355-
}
356-
set {
357-
radius = newValue / 2
358-
}
359-
}
360-
361-
init(x: Int, y: Int, radius: Double) {
362-
self.x = x
363-
self.y = y
364-
self.radius = radius
365-
}
366-
367-
convenience init(x: Int, y: Int, diameter: Double) {
368-
self.init(x: x, y: y, radius: diameter / 2)
369-
}
370-
371-
func describe() -> String {
372-
return "I am a circle at \(centerString()) with an area of \(computeArea())"
373-
}
374-
375-
override func computeArea() -> Double {
376-
return M_PI * radius * radius
377-
}
378-
379-
private func centerString() -> String {
380-
return "(\(x),\(y))"
381-
}
382-
}
383-
```
384-
385-
The example above demonstrates the following style guidelines:
386-
387-
+ Specify types for properties, variables, constants, argument declarations and other statements with a space after the colon but not before, e.g. `x: Int`, and `Circle: Shape`.
388-
+ Define multiple variables and structures on a single line if they share a common purpose / context.
389-
+ Indent getter and setter definitions and property observers.
390-
+ Don't add modifiers such as `internal` when they're already the default. Similarly, don't repeat the access modifier when overriding a method.
391-
392343
### Use of Self
393344

394345
For conciseness, avoid using `self` since Swift does not require it to access an object's properties or invoke its methods.

0 commit comments

Comments
 (0)