@@ -386,17 +386,17 @@ variables was a type object with such a constraint, which is not initializeable,
386
386
thus you cannot use the C < .= > operator, for example.
387
387
388
388
= for code :solo
389
- use v6.c;
390
- my Int:D $x .= new: 42;
391
- # OUTPUT: You cannot create an instance of this type (Int:D)
392
- # in block <unit> at -e line 1
389
+ use v6.c;
390
+ my Int:D $x .= new: 42;
391
+ # OUTPUT: You cannot create an instance of this type (Int:D)
392
+ # in block <unit> at -e line 1
393
393
394
394
In the 6.d language, the default default is the type object without the smiley
395
395
constraint:
396
396
397
397
= for code :solo
398
- use v6.d;
399
- my Int:D $x .= new: 42; # OUTPUT: «42»
398
+ use v6.d;
399
+ my Int:D $x .= new: 42; # OUTPUT: «42»
400
400
401
401
A closing remark on terminology: this section is about the use of the type
402
402
smileys C < :D > and C < :U > to constrain the definiteness of arguments.
@@ -504,31 +504,31 @@ as C«-->» with the caveat that this form does not work with constant values. Y
504
504
cannot use it in a block either. That is why the pointy arrow form is always
505
505
preferred.
506
506
507
- = for code
508
- sub greeting(Str $name) returns Str { say "Hello, $name" } # Valid
507
+ = for code
508
+ sub greeting(Str $name) returns Str { say "Hello, $name" } # Valid
509
509
510
- = for code :skip-test<compile time error>
511
- sub favorite-number returns 42 { } # This will fail.
510
+ = for code :skip-test<compile time error>
511
+ sub favorite-number returns 42 { } # This will fail.
512
512
513
513
= head4 C < of >
514
514
515
515
C < of > is just the real name of the C < returns > keyword.
516
516
517
- = for code
518
- sub foo() of Int { 42 }; # Valid
517
+ = for code
518
+ sub foo() of Int { 42 }; # Valid
519
519
520
- = for code :skip-test<compile time error>
521
- sub foo() of 42 { }; # This will fail.
520
+ = for code :skip-test<compile time error>
521
+ sub foo() of 42 { }; # This will fail.
522
522
523
523
= head4 prefix(C-like) form
524
524
525
525
This is similar to placing type constraints on variables like C < my Type $var =
526
526
20; > , except the C < $var > is a definition for a routine.
527
527
528
- = for code
529
- my Int sub bar { 1 }; # Valid
530
- = for code :skip-test<compile time error>
531
- my 42 sub bad-answer {}; # This will fail.
528
+ = for code
529
+ my Int sub bar { 1 }; # Valid
530
+ = for code :skip-test<compile time error>
531
+ my 42 sub bad-answer {}; # This will fail.
532
532
533
533
= head3 X < Coercion type >
534
534
0 commit comments