Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[subs-n-sigs] optional parameters; convert to UTF-8
  • Loading branch information
moritz committed Mar 28, 2010
1 parent 2261e8a commit f4b0b90
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/subs-n-sigs.pod
Expand Up @@ -98,7 +98,7 @@ sub order-beer($type, $pints) {
}

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

=end programlisting

Expand Down Expand Up @@ -200,6 +200,22 @@ just not needed in every situation. In these cases, it is nice to mark such
parameters as optional, so those calling the subroutine can choose whether or
not they want to pass a value.

This can be done by assigning a default value in the signature, or by
appending a question mark to the parameter name:

=begin programlisting

# with a default value
sub order-steak($how = 'medium') {
say "I'd like a steak, $how";
}
order-steak();
order-steak('through');

# without a defalt value
# TODO: come up with a good example

=end programlisting

=head2 Named Paramters

Expand Down

0 comments on commit f4b0b90

Please sign in to comment.