Course of Raku / Advanced / Containers / Introspecting containers / Exercises / Describe a variable
Solution: Describe a variable
Here is a possible solution to the task.
Code
my Str $lang = 'Raku';
say $lang.^name;
say $lang.VAR.^name;
say $lang.VAR.name;🦋 You can find the source code in the file describe-a-variable.raku.
Output
Str
Scalar
$langComments
.^namereturns the type of the value stored in the container, which isStr..VARreturns the underlying container, and.^nameon it returnsScalar— the type of the container itself..VAR.namereturns the name of the variable,$lang, including its sigil. Note that this is thenamemethod, not the^namemeta-method used on the first two lines.