File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
content/courses/intro-to-ada/chapters Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -227,17 +227,23 @@ to explicitly store it in a local variable.
227227 return I * 2;
228228 end Double;
229229
230- Res : Integer := Double (Double (I));
231- -- ^ Calling the Double
232- -- function
230+ Res : Integer;
233231 begin
234- Double (I );
232+ Double (Double (I) );
235233 -- ERROR: cannot use call to function
236234 -- "Double" as a statement
237235
236+ Res := Double (Double (I));
237+ -- OK: return value of Double is
238+ -- assigned to Res
239+
238240 return Res;
239241 end Quadruple;
240242
243+ A statement such as :ada: `Double (Double (I)); ` is wrong because we're not
244+ assigning the return value to a variable |mdash | we can correct this statement
245+ by writing :ada: `Res := Double (Double (I)); `.
246+
241247.. admonition :: In the GNAT toolchain
242248
243249 In GNAT, with all warnings activated, it becomes even harder to ignore the
You can’t perform that action at this time.
0 commit comments