Skip to content

Commit f96ce35

Browse files
committed
doc trusts
1 parent 3624102 commit f96ce35

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

doc/Language/typesystem.pod6

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,23 @@ TODO
182182
183183
=head3 trait C<trusts>
184184
185+
To allow one class to access the private methods of another class use the trait
186+
C<trusts>. A forward declaration of the tuested class may be required.
187+
188+
class B {...};
189+
class A {
190+
trusts B;
191+
has $!foo;
192+
method !foo { return-rw $!foo }
193+
method perl { "A.new(foo => $!foo)" }
194+
};
195+
class B {
196+
has A $.a .= new;
197+
method change { $!a!A::foo = 42; self }
198+
};
199+
say B.new.change;
200+
OUTPUT«B.new(a => A.new(foo => 42))␤»
201+
185202
TODO
186203
187204
=head3 Versioning and Authership

0 commit comments

Comments
 (0)