📘 Hash in Perl 6

Hashes provide a few methods with clear semantics, for instance: my %hash = Language => ‘Perl’, Version => 6; say %hash.elems;  # number of pairs in the hash say %hash.keys;   # the list of the keys say %hash.values; # the list of the values Here’s the output:  2 (Version Language) (6 Perl) It is possible … Continue reading “📘 Hash in Perl 6”

📘 Typed variables in Perl 6

This is how you declare a typed variable: my Int $x; Here, a scalar container $x may only hold an integer value. Attempts to assign it a value that is not an integer leads to an error: my Int $x; $x = “abc”; # Error: Type check failed in assignment to ‘$x’;             # expected … Continue reading “📘 Typed variables in Perl 6”