There's also a Python version of this[1], which starts with a discussion about Perl 6's equivalent of print, which is put. This makes no sense to me whatsoever, as print is both a much easier way to say it and _what was used in Perl 5_, but not my circus, not my monkeys. But then it goes on to say: > There is also say, which behaves similarly, but will call the gist method of its argument. And after having read the l…
print in Perl 6 works the same as print in Perl 5. put/say are output functions which automatically add a newline at the end. If you want fancier formatting, printf is available as well. And notice the relative lengths of these names. As much as possible, p6 is organized so that the more commonly used thing will have the shorter name. PS I don't think I have ever used put in p6. My code uses say, or print if I don't…
class Chemical {
has $.formula;
method gist {
my $output = $!formula;
$output ~~ s:g/()/{(0x2080+$0).chr}/;
$output;
}
}
my $chem = Chemical.new(formula => 'Al6O13Si2');
say $chem; # Al₆O₁₃Si₂
#`[
Without overriding the `gist` method:
say $chem; # Chemical.new(formula => 'Al6O13Si2')
]