File tree Expand file tree Collapse file tree 1 file changed +21
-6
lines changed
courses/fundamentals_of_ada/070_subprograms Expand file tree Collapse file tree 1 file changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -60,14 +60,29 @@ Which statement is True?
60
60
61
61
A. Expression functions cannot be nested functions.
62
62
B. Expression functions require a specification and a body.
63
- C. Expression functions must have at least one " return" statement.
63
+ C. Expression functions must have at least one :ada: ` return ` statement.
64
64
D. :answer: `Expression functions can have "out" parameters. `
65
65
66
66
.. container :: animate
67
67
68
- Explanations
68
+ Explanation
69
69
70
- A. False, they can be declared just like regular function
71
- B. False, an expression function cannot have a body
72
- C. False, expression functions cannot contain a no :ada: `return `
73
- D. Correct, but it can assign to :ada: `out ` parameters only by calling another function.
70
+ A. They **can ** be nested subprograms (just like any other subprogram)
71
+ B. As in other subprograms, the implementation can serve as the specification
72
+ C. Because they are expressions, the :ada: `return ` statement is not allowed
73
+ D. An expression function does not allow assignment statements, but it can call another function that is **not ** an expression function.
74
+
75
+ .. code :: Ada
76
+
77
+ function Normal_Fun (Input : Character;
78
+ Output : out Integer)
79
+ return Boolean is
80
+ begin
81
+ Output := Character'Pos (Input);
82
+ return True;
83
+ end Normal_Fun;
84
+
85
+ function Expr_Fun (Input : Character;
86
+ Output : out Integer)
87
+ return Boolean is
88
+ (Normal_Fun (Character'Succ (Input), Output));
You can’t perform that action at this time.
0 commit comments