mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
[swift/en] describe convenience initializers (#4836)
This commit is contained in:
parent
fbb67906c1
commit
b8d2f410a8
@ -679,6 +679,9 @@ class Rect: Shape {
|
||||
|
||||
// A simple class `Square` extends `Rect`
|
||||
class Square: Rect {
|
||||
// Use a convenience initializer to make calling a designated initializer faster and more "convenient".
|
||||
// Convenience initializers call other initializers in the same class and pass default values to one or more of their parameters.
|
||||
// Convenience initializers can have parameters as well, which are useful to customize the called initializer parameters or choose a proper initializer based on the value passed.
|
||||
convenience init() {
|
||||
self.init(sideLength: 5)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user