Course of Raku / Advanced / Containers / Introspecting containers / Exercises / What is it
Solution: What is it
Here is a possible solution to the task.
Code
my $a = 42;
my $b = 'x';
say $a.WHAT === Int;
say $b.WHAT === Int;🦋 You can find the source code in the file what-is-it.raku.
Output
True
FalseComments
$a.WHATis not the stringIntbut the actualInttype object, so=== Intcompares it against the type itself and returnsTrue.$bholds a string, so itsWHATisStr; comparing that withIntgivesFalse. This is what makesWHATuseful in conditions, not just in printouts.