Skip to content

Commit acfbf32

Browse files
committed
Adds documentation for object equality
It's actually another example of the documentation already in the eqv description. Anyway, closes #2004
1 parent 6de783d commit acfbf32

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

doc/Language/objects.pod6

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,24 @@ and assign to the container it returned with the L<C<=>|/routine/=> operator.
8383
All objects support methods from class L<Mu|/type/Mu>, which is the type
8484
hierarchy root. All objects derive from C<Mu>.
8585
86+
Object equality needs a specific operator:
87+
L<C<eqv>|/language/operators#infix_eqv>, the structural comparison
88+
operator:
89+
90+
=for code
91+
class Foo {
92+
has $.bar;
93+
has $.baz
94+
};
95+
my $bar = "42";
96+
my $baz = 24;
97+
my $zipi = Foo.new( :$baz, :$bar);
98+
my $zape = Foo.new( :$bar, :$baz);
99+
say $zipi eqv $zape; # OUTPUT: «True␤»
100+
101+
Object identity, on the other hand, uses C<===>. Using it above will return
102+
C<False>, for instance.
103+
86104
X<|Type objects>
87105
=head2 Type objects
88106

0 commit comments

Comments
 (0)