Course of Raku / Advanced / Subroutines / Nested subroutines / Exercises / A private helper
Solution: A private helper
Here is a possible solution to the task.
Code
sub stats {
sub double($x) { $x * 2 }
say double(3) + double(5);
}
stats;🦋 You can find the source code in the file private-helper.raku.
Output
16Comments
The helper
doubleis defined insidestats, so it is visible only there and cannot be called from elsewhere in the program.statsuses it twice:double(3)is6anddouble(5)is10, and their sum is16.