Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Improve example with explicit state
Using state in `where` clause is UB and should not be shown in the docs.
  • Loading branch information
zoffixznet committed Jul 29, 2018
1 parent eb0c969 commit 1b9e1e5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions doc/Language/variables.pod6
Expand Up @@ -714,9 +714,9 @@ itself, not the expression that may contain an initializer. If the
initializer has to be called exactly once, the C<state> declarator has to be
provided.
=begin code :skip-test
subset DynInt where $ = ::('Int'); # the initializer will be called for each type check
subset DynInt where state $ = ::('Int'); # the initializer is called once, this is a proper cache
=begin code
for ^3 { $ = .say } # OUTPUT: «0␤1␤2␤»
for ^3 { state $ = .say } # OUTPUT: «0␤»
=end code
=head3 The C<@> variable
Expand Down

0 comments on commit 1b9e1e5

Please sign in to comment.