Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[subs-n-sigs] some small improvments; clarify that binding a constant…
… to an rw-parameter fails
  • Loading branch information
moritz committed Mar 28, 2010
1 parent 71bee89 commit 2261e8a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions Makefile
@@ -1,6 +1,7 @@
CHAPTERS =src/preface.pod \
src/basics.pod \
src/operators.pod \
src/subs-n-sigs.pod \
src/multi-dispatch.pod \
src/classes-and-objects.pod \
src/regexes.pod \
Expand Down
11 changes: 6 additions & 5 deletions src/subs-n-sigs.pod
Expand Up @@ -93,12 +93,12 @@ that incoming arguments should be bound to.

=begin programlisting

sub order_beer($type, $pints) {
sub order-beer($type, $pints) {
say ($pints == 1 ?? 'A pint' !! "$pints pints") ~ " of $type, please."
}

order_beer('Hobgoblin', 1); # A pint of Hobgoblin, please.
order_beer('Zlat� Ba�ant', 3); # 3 pints of Zlat� Ba�ant, please.
order-beer('Hobgoblin', 1); # A pint of Hobgoblin, please.
order-beer('Zlat� Ba�ant', 3); # 3 pints of Zlat� Ba�ant, please.

=end programlisting

Expand All @@ -109,8 +109,9 @@ too limiting, then you have two different ways to relax this restriction.

Marking a parameter as C<is rw> means that you are allowed to modify the
argument that was passed in. Doing so modifies the original thing that was
passed. If a literal or some other constant value was passed in, then this
will fail.
passed. If a literal or some other constant value was passed in for an rw
parameter, then binding of the signature fails, and the subroutine cannot be
called with the constant argument.

=begin programlisting

Expand Down

0 comments on commit 2261e8a

Please sign in to comment.