smol projects

raku is... interesting

06.10.2023 1 min read

I’ve been playing with raku for the better part of a day, and… it’s interesting, for sure.

nude returns the numerator and denominator as a list. You should probably not try to find documentation for this through your normal search engine.

You get the type of a variable by calling the method .WHAT. No, my caps key isn’t broken.


lexically-scoped variables are my, e.g. my $var = 42;. our is package-scoped.

Sigils are everywhere, and they’re supposed to denote the type of a variable:

  • $ any
  • % map
  • @ array

(I actually kind of like this, lol)

Assigning a Nil value to a variable makes it Any - calling it inline keeps it as Nil. Docs

You open a file with slurp - like, slup("path/to/file)". It’s counterpart, spurt, writes to one.

Writing a leftpad is easy, because you have the x operator. Yes, x, not *.

sub right_pad(Str $str, Int $n) {
    " " x $n ~ $str;

Oh yeah, you do string concatenation with ~.

You have rational numbers (Rat) and (FatRat).

And all this is probably just the tip of the iceberg. This is day one of Raku, and I don’t think I’ll continue using it, LOL. But it’s interesting, for sure…

Built with Astro and Tailwind 🚀