Raku / doc

🦋 Raku documentation
https://docs.raku.org/
Artistic License 2.0
291 stars 293 forks source link

Add practical examples of using Allomorphs, e.g., changing a Str Allomorph to an Int. #4483

Closed tbrowder closed 6 months ago

tbrowder commented 6 months ago

Problem or new feature

The docs go into great detail about the Allomorphs and how to create them from a literal number. However, how to change an Allomorph-like variable from one of its forms to the other is not shown.

Suggestions

In the Numerics section, add examples like this:

# Create a string that could be an Allomorph (but isn't)
my $a = "010";
say $a.^name;               # OUTPUT: Str (note: not Allomorph)
# Change to an Int representation:
$a .= Numeric;
say $a;                            # OUTPUT: 10
say $a.^name;               # OUTPUT: Int (note: not Allomorph)