Skip to content

Commit

Permalink
make examples compile
Browse files Browse the repository at this point in the history
  • Loading branch information
gfldex committed Aug 7, 2016
1 parent 8e4234a commit 8cac1b2
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions doc/Language/typesystem.pod6
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ C<trusts>. A forward declaration of the tuested class may be required.
method change { $!a!A::foo = 42; self }
};
say B.new.change;
OUTPUT«B.new(a => A.new(foo => 42))␤»
# OUTPUT«B.new(a => A.new(foo => 42))␤»
TODO
Expand Down Expand Up @@ -259,6 +259,7 @@ Stringification of the symbol will provide the key of the enum-pair.
Comparing symbols will use type information and the value of the enum-pair. As
value types C<Numerical> an C<Str> are supported.
enum Names ( name1 => 1, name2 => 2 );
sub same(Names $a, Names $b){
$a eqv $b
}
Expand Down Expand Up @@ -312,32 +313,38 @@ Returns the list of enum-pairs. Works both on the enum type and any key.
Returns the key of an enum-pair.
=for code :skip-test
say g.key; # OUTPUT«g␤»
=head4 method value
Returns the value of an enum-pair.
=for code :skip-test
say g.value; # OUTPUT«1␤»
=head4 method pair
Defined as:
=for code :skip-test
method pair(::?CLASS:D:)
Returns a C<Pair> of the enum-pair.
=for code :skip-test
say g.pair; # OUTPUT«g => 1␤»
=head4 method kv
Defined as:
=for code :skip-test
multi method kv(::?CLASS:D:)
Returns a list with key and value of the enum-pair.
=for code :skip-test
say g.kv; # OUTPUT«(g 1)␤»
Expand Down Expand Up @@ -383,6 +390,8 @@ will be checked against the given code object.
subset Positive of Int where * > -1;
my Positive $i = 1;
$i = -42; # OUTPUT«Type check failed in assignment to $i; expected Positive but got Int (-42)␤ …»
$i = -42;
CATCH { default { put .^name,': ', .Str } }
# OUTPUT«X::TypeCheck::Assignment: Type check failed in assignment to $i; expected Positive but got Int (-42)␤ …»
=end pod

0 comments on commit 8cac1b2

Please sign in to comment.