From 771459b110dcf1f92d32b77bbb9ff428aa6c3843 Mon Sep 17 00:00:00 2001 From: Ilunga Gisa Daniel <71249922+danielerat@users.noreply.github.com> Date: Mon, 25 Nov 2024 16:55:50 +0200 Subject: [PATCH] Update generative constructor example to not override default value (#6206) Update documentation for generative constructor by dropping the value assigned in the field definitions. This allows the example to focus on generative constructors, as the section is titled. --------- Co-authored-by: Marya <111139605+MaryaBelanger@users.noreply.github.com> Co-authored-by: Parker Lougheed --- examples/misc/lib/language_tour/classes/point_alt.dart | 6 +++--- src/content/language/constructors.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/misc/lib/language_tour/classes/point_alt.dart b/examples/misc/lib/language_tour/classes/point_alt.dart index b7dc8cb98b..f148a7decc 100644 --- a/examples/misc/lib/language_tour/classes/point_alt.dart +++ b/examples/misc/lib/language_tour/classes/point_alt.dart @@ -6,9 +6,9 @@ /// // #docregion idiomatic-constructor 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); diff --git a/src/content/language/constructors.md b/src/content/language/constructors.md index f1a1201d23..de0d5e4bd3 100644 --- a/src/content/language/constructors.md +++ b/src/content/language/constructors.md @@ -51,9 +51,9 @@ 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);