Skip to content

Commit a2b5418

Browse files
committed
Insure some examples compile
1 parent 3134fb2 commit a2b5418

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

doc/Type/Signature.pod6

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ Normally, a type constraint only checks whether the value of the parameter is of
217217
correct type. Crucially, both I<object instances> and I<type objects> will satisfy
218218
such a constraint as illustrated below:
219219
220-
say 42.WHAT # OUTPUT: «(Int)␤»
221-
say 42 ~~ Int # OUTPUT: «True␤»
222-
say Int ~~ Int # OUTPUT: «True␤»
220+
say 42.^name; # OUTPUT: «Int␤»
221+
say 42 ~~ Int; # OUTPUT: «True␤»
222+
say Int ~~ Int; # OUTPUT: «True␤»
223223
224224
Note how both C<42> and C<Int> satisfy the match.
225225
@@ -246,8 +246,8 @@ its L<DEFINITE|/language/mop#DEFINITE> method.
246246
247247
To warm up, let's apply C<:D> to the right hand side of our humble C<Int> example:
248248
249-
say 42 ~~ Int:D # OUTPUT: «True␤»
250-
say Int ~~ Int:D # OUTPUT: «False␤»
249+
say 42 ~~ Int:D; # OUTPUT: «True␤»
250+
say Int ~~ Int:D; # OUTPUT: «False␤»
251251
252252
Note how only C<42> matches C<Int:D> in the above.
253253
@@ -269,8 +269,8 @@ constraint, which checks whether the value passed is a type object
269269
rather than an object instance. Here's our C<Int> example again, this
270270
time with C<:U> applied:
271271
272-
say 42 ~~ Int:U # OUTPUT: «False␤»
273-
say Int ~~ Int:U # OUTPUT: «True␤»
272+
say 42 ~~ Int:U; # OUTPUT: «False␤»
273+
say Int ~~ Int:U; # OUTPUT: «True␤»
274274
275275
Now C<42> fails to match C<Int:U> while C<Int> succeeds.
276276
@@ -288,6 +288,7 @@ Here's a more practical example:
288288
Calling C<can-turn-into> with an object instance as its second parameter
289289
will yield a constraint violation as intended:
290290
291+
=for code :preamble< sub can-turn-into(Str $, Any:U $) {...}>
291292
say can-turn-into("a string", 123);
292293
# OUTPUT: «Parameter '$type' of routine 'can-turn-into' must be a type object of type 'Any', not an object instance of type 'Int'...»
293294

0 commit comments

Comments
 (0)