Course of Raku / Advanced / More about built-in types / Quoting constructs 🆕 / Exercises
A closure in a q string
Problem
Start from the non-interpolating q form and switch on
the closure adverb only. Given a variable $x holding
10, print a line that contains the embedded calculation
{$x ** 2} and a literal, un-interpolated
$x. This shows that the closure adverb evaluates code in
braces while leaving plain $ variables untouched.
Example
The program prints:
$x squared is 100Solution
Course navigation
← Solution: A raw string | Solution: A closure in a q string →