@@ -28,8 +28,14 @@ The immutable version of a C<Pair> is an C<Enum>.
28
28
29
29
= head2 method antipair
30
30
31
+ Defined as:
32
+
31
33
method antipair() returns Pair:D
32
34
35
+ Usage:
36
+
37
+ PAIR.antipair
38
+
33
39
Returns a new C < Pair > object with key and value exchanged.
34
40
35
41
my $p = (6 => 'Perl').antipair;
@@ -38,21 +44,39 @@ Returns a new C<Pair> object with key and value exchanged.
38
44
39
45
= head2 method value
40
46
47
+ Defined as:
48
+
41
49
multi method value(Pair:D:) is rw
42
50
51
+ Usage:
52
+
53
+ PAIR.value
54
+
43
55
Returns the I < value > part of the C < Pair > .
44
56
45
57
= head2 infix cmp
46
58
59
+ Defined as:
60
+
47
61
multi sub infix:<cmp>(Pair:D, Pair:D)
48
62
63
+ Usage:
64
+
65
+ PAIR1 cmp PAIR2
66
+
49
67
The type-agnostic comparator; compares two C < Pair > s. Compares first their
50
68
I < key > parts, and then compares the I < value > parts if the keys are equal.
51
69
52
70
= head2 method fmt
53
71
72
+ Defined as:
73
+
54
74
multi method fmt(Pair:D:) returns Str:D
55
75
76
+ Usage:
77
+
78
+ PAIR.fmt(FORMATSTRING)
79
+
56
80
Takes a I < format string > , and returns a string the I < key > and I < value >
57
81
parts of the C < Pair > formatted. Here's an example:
58
82
@@ -64,17 +88,29 @@ For more about format strings, see L<sprintf>.
64
88
65
89
= head2 method kv
66
90
91
+ Defined as:
92
+
67
93
multi method kv(Pair:D:) returns List:D
68
94
95
+ Usage:
96
+
97
+ PAIR.kv
98
+
69
99
Returns a two-element C < List > with the I < key > and I < value > parts of
70
100
C < Pair > , in that order. This method is a special case of the same-named
71
101
method on C < Hash > , which returns all its entries as a list of keys and
72
102
values.
73
103
74
104
= head2 method pairs
75
105
106
+ Defined as:
107
+
76
108
multi method pairs(Pair:D:)
77
109
110
+ Usage:
111
+
112
+ PAIR.pairs
113
+
78
114
Returns a list of one C < Pair > , namely this one.
79
115
80
116
= end pod
0 commit comments