raku.gg

[ BACK... ]
By: w1ldc4rd-w1z4rd

Overview


Q: The No-Nonsense Quote

Meet Q, the straightforward member of the quoting family. It’s refreshingly simple:

say Q[This is exactly what you'll see];
say No surprises here either」;
say Q^Yep, still literal^;

Q is your go-to when you want your text untouched and uninterpreted. It’s like a “what you see is what you get” deal for strings.

q: The Escape Artist

Next up is q, which introduces a bit more flexibility with its backslash escapes:

Here are some quick examples:

say q[This \n is just a backslash and 'n'];
say q{$variable won't be interpolated};
say q/Use any (delimiter) you like/;
say q{Escape the closing delimiter like this: \}};

When to use q: - Working with Windows file paths - Writing regex patterns - Ensuring no accidental interpolation

Remember, with q, what you type is (almost always) what you get!

qq: The Interpolation Maestro

Now, let’s welcome qq, the star of the show when it comes to dynamic strings:

my $mood = 'excited';
my $reason = 'Raku';
say qq[I'm feeling $mood about $reason!];

qq lets your strings come alive, seamlessly incorporating variables and expressions.

Heredocs: For When You Have a Lot to Say

Sometimes, you need to quote a whole paragraph or more. That’s where heredocs shine:

my $manifesto = q:to/END/;
    We, the programmers of the world,
    Solemnly swear to write clean code,
    To comment our obscure hacks,
    And to always back up our work.
END

say $manifesto;

Perfect for those moments when a single line just won’t cut it.

Wrapping Up

Raku’s quoting constructs are a playground for text manipulation. From the stoic Q to the dynamic qq, and the powerful adverbs, you’ve got a full toolkit at your disposal.

Remember, mastering Raku’s quoting constructs is a journey. Start with the basics, and gradually incorporate more advanced features as you become comfortable. Before you know it, you’ll be quoting like a pro!

WWW: 🐪 perl.gg - 🧙‍♂️ clc.onl - 💾 GitHub - 🏙️ Neocities

Copyright ©️ 2024 raku.gg