File tree Expand file tree Collapse file tree 3 files changed +4
-4
lines changed
examples/misc/lib/effective_dart
src/content/effective-dart Expand file tree Collapse file tree 3 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ void miscDeclAnalyzedButNotTested() {
132132 {
133133 // #docregion cast-map
134134 var stuff = < dynamic > [1 , 2 ];
135- var reciprocals = stuff.map ((n) => 1 / (n as int ) ).cast <double >();
135+ var reciprocals = stuff.map ((n) => n * 2 ).cast <double >();
136136 // #enddocregion cast-map
137137 }
138138
Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ void miscDeclAnalyzedButNotTested() {
114114 {
115115 // #docregion cast-map
116116 var stuff = < dynamic > [1 , 2 ];
117- var reciprocals = stuff.map <double >((n) => 1 / (n as int ));
117+ var reciprocals = stuff.map <double >((n) => (n as int ) * 2 );
118118 // #enddocregion cast-map
119119 }
120120
Original file line number Diff line number Diff line change @@ -749,13 +749,13 @@ to be explicit.
749749<? code-excerpt "usage_good.dart (cast-map)" replace="/\(n as int\)/n/g"?>
750750``` dart tag=good
751751var stuff = <dynamic>[1, 2];
752- var reciprocals = stuff.map<double>((n) => 1 / n );
752+ var reciprocals = stuff.map<double>((n) => n * 2 );
753753```
754754
755755<? code-excerpt "usage_bad.dart (cast-map)" replace="/\(n as int\)/n/g"?>
756756``` dart tag=bad
757757var stuff = <dynamic>[1, 2];
758- var reciprocals = stuff.map((n) => 1 / n ).cast<double>();
758+ var reciprocals = stuff.map((n) => n * 2 ).cast<double>();
759759```
760760
761761
You can’t perform that action at this time.
0 commit comments