🔬 75. my $x = $x in Perl 6

What happens if you’ll try to create a new variable and immediately initialise it by itself, as shown in the following test code: my $x = $x; This does not work (which is expected), but Perl 6 is so kind to the user  that it gives an error message prepared especially for this case: ===SORRY!=== … Continue reading “🔬 75. my $x = $x in Perl 6”

🦋 74. Typed hashes in Perl 6

In Perl 6, you can restrict the content of a variable container by specifying its type, for example: my Int $i; There is only one value in a scalar variable. You can extend the concept to arrays and let its element to keep only integers, as it is done in the next example: > my … Continue reading “🦋 74. Typed hashes in Perl 6”

🔬73. Keys, values, etc. of hashes in Perl 6

Today, we will take a look at a few methods of the Hash class that return all hash keys or values or both: > my %h = H => ‘Hydrogen’, He => ‘Helium’, Li => ‘Lithium’; {H => Hydrogen, He => Helium, Li => Lithium} > %h.keys; (H Li He) > %h.values; (Hydrogen Lithium Helium) … Continue reading “🔬73. Keys, values, etc. of hashes in Perl 6”

🔬72. Superscripts in Perl 6

In Perl 6, you can use superscript indices to calculate powers of numbers, for example: > 2⁵ 32 > 7³ 343 It also works with more than one digit in the superscript: > 10¹² 1000000000000 You can guess that the above cases are equivalent to the following: > 2**5 32 > 7**3 343 > 10**12 … Continue reading “🔬72. Superscripts in Perl 6”

🔬71. Implementing Int.sleep() in Perl 6

Hello! Yesterday, I was giving my Perl 6 Intro course at the German Perl Workshop in Gummersbash. It was a great pleasure to prepare and run this one-day course, and, while it was difficult to cover everything, we touched all main aspects of the Perl 6 language: from variables to regexes and parallel computing. Of … Continue reading “🔬71. Implementing Int.sleep() in Perl 6”