From 8e1977e7aa8b49ec2cc48e954d1b024f49e5d379 Mon Sep 17 00:00:00 2001 From: Ilunga Gisa Daniel <71249922+danielerat@users.noreply.github.com> Date: Thu, 14 Nov 2024 12:33:03 +0200 Subject: [PATCH] Update documentation for generative constructor with optional positional parameters - Updated the example for generative constructors to reflect the use of optional positional parameters with default values. - Clarified the behavior of the constructor to indicate that `x` and `y` have default values of 2.0 when not passed explicitly. --- src/content/language/constructors.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/content/language/constructors.md b/src/content/language/constructors.md index f1a1201d23..bb7c3f1226 100644 --- a/src/content/language/constructors.md +++ b/src/content/language/constructors.md @@ -51,12 +51,12 @@ To instantiate a class, use a generative constructor. ```dart class Point { - // Initializer list of variables and values - double x = 2.0; - double y = 2.0; + // Instance variables to hold the coordinates of the point. + double x; + double y; - // Generative constructor with initializing formal parameters: - Point(this.x, this.y); + // Generative constructor with optional positional parameters and default values. + Point([this.x = 2.0, this.y = 2.0]); } ```