File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change
1
+ = begin pod
2
+
3
+ = TITLE class StrDistance
4
+
5
+ = SUBTITLE Contains the result of a string transformation.
6
+
7
+ C < StrDistance > objects are used to represent the return of the L < tr|https://docs.perl6.org/syntax/tr$SOLIDUS$SOLIDUS$SOLIDUS > operator.
8
+
9
+ say (($ = "fold") ~~ tr/old/new/).^name;# OUTPUT: «StrDistance»
10
+
11
+ A C < StrDistance > object will stringify to the resulting string after the transformation, and will numify to the distance between the two strings.
12
+
13
+ = begin code
14
+ my $str = "fold";
15
+ my $str-dist = ($str ~~ tr/old/new/);
16
+ say ~$str-dist; # OUTPUT: «fnew»
17
+ say +$str-dist; # OUTPUT: «3» │
18
+ = end code
19
+
20
+ = head1 Methods
21
+
22
+ = head2 before
23
+
24
+ Property that returns the string before the transformation:
25
+
26
+ = for code :preamble<my $str = "fold"; my $str-dist = ($str ~~ tr/old/new/); >
27
+ say $str-dist.before; #OUTPUT: «fold»
28
+
29
+ = head2 after
30
+
31
+ Returns the string after the transformation
32
+
33
+ = for code :preamble<my $str = "fold"; my $str-dist = ($str ~~ tr/old/new/); >
34
+ say $str-dist.after; #OUTPUT: «fnew»
35
+
36
+ = end pod
37
+
38
+ # vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6
Original file line number Diff line number Diff line change @@ -381,6 +381,7 @@ findmethod
381
381
flatmap
382
382
flipflop
383
383
fmt
384
+ fnew
384
385
foreach
385
386
formatter
386
387
formline
@@ -850,6 +851,7 @@ plaintext
850
851
pluggable
851
852
png
852
853
podtohtml
854
+ polation
853
855
polymod
854
856
polymorphism
855
857
portably
@@ -1371,4 +1373,3 @@ yyyy
1371
1373
zef
1372
1374
zoffixznet
1373
1375
zwj
1374
- polation
You can’t perform that action at this time.
0 commit comments