summaryrefslogtreecommitdiffhomepage
path: root/swift.html.markdown
diff options
context:
space:
mode:
authorEdoardo La Greca <35077726+EdoardoLaGreca@users.noreply.github.com>2024-02-10 14:37:32 +0100
committerGitHub <noreply@github.com>2024-02-10 14:37:32 +0100
commitb8d2f410a838c49836e2572c8a3c682709153671 (patch)
tree33691d8e9df1e25ddaf0706250987d4ef1f6638f /swift.html.markdown
parentfbb67906c125d31563e9620fc9656de60c9067e3 (diff)
[swift/en] describe convenience initializers (#4836)
Diffstat (limited to 'swift.html.markdown')
-rw-r--r--swift.html.markdown3
1 files changed, 3 insertions, 0 deletions
diff --git a/swift.html.markdown b/swift.html.markdown
index e46dcc75..36124e11 100644
--- a/swift.html.markdown
+++ b/swift.html.markdown
@@ -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)
}