Unless I missed something, constants aren't covered at all in the course. Constants are worthy of mention, most likely in the Variables and Data Types Essentials section. It should be noted that in Raku, unlike Perl, constants can be lexically scoped with my just like a variable.
Thus, this code works as expected:
my constant $A="bar";
sub foo {
my constant $A="foo";
say $A;
}
foo();
say $A;
The user can expect the following output:
$ ./constant.raku
foo
bar
Attempts to redefine a constant will throw an error. Given the importance of read-only variables in FP, this is all worth revisiting in Course 5: Functional, Concurrent, and Reactive Programming.
Unless I missed something, constants aren't covered at all in the course. Constants are worthy of mention, most likely in the Variables and Data Types Essentials section. It should be noted that in Raku, unlike Perl, constants can be lexically scoped with
my
just like a variable.Thus, this code works as expected:
The user can expect the following output:
Attempts to redefine a constant will throw an error. Given the importance of read-only variables in FP, this is all worth revisiting in Course 5: Functional, Concurrent, and Reactive Programming.