Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #2563 from Kaiepi/traps
Document trap on set subroutines on Associative
  • Loading branch information
lizmat committed Jan 13, 2019
2 parents 69e7e3a + 2f8a1c1 commit ca3067e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions doc/Language/traps.pod6
Expand Up @@ -152,6 +152,31 @@ Alternatively, you can also use the L<concatenation operator|/routine/~> instead
sub count-it { say "Count is " ~ $++ }
=end code
=head2 Using set subroutines on Associative when the value is falsey
Using L<(cont)|/routine/(cont)>, L<∋|/routine/∋>, L<∌|/routine/∌>,
L<(elem)|/routine/(elem)>, L<∈|/routine/∈>, or L<∉|/routine/∉> on classes
implementing L<Associative|/type/Associative> will return C<False> if the value
of the key is falsey:
=begin code
enum Foo «a b»;
say Foo.enums ∋ 'a';
# OUTPUT:
# False
=end code
Instead, use C<:exists>:
=begin code
enum Foo «a b»;
say Foo.enums<a>:exists;
# OUTPUT:
# True
=end code
=head1 Blocks
=head2 Beware of empty "blocks"
Expand Down

0 comments on commit ca3067e

Please sign in to comment.