-
Notifications
You must be signed in to change notification settings - Fork 12
Constants Should Be Covered in Raku Essentials #17
Copy link
Copy link
Open
Description
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels