|
|
|
|
|
by xisukar
2793 days ago
|
|
As for the say function, it's also supposed to output text in a more human readable format. It calls the `.gist` of its argument, which you can override in user-defined classes. Take for example the following code snippet from Perl 6 Deep Dive: class Chemical {
has $.formula;
method gist {
my $output = $!formula;
$output ~~ s:g/(<[0..9]>)/{(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')
]
|
|