Skip to content
This repository
Browse code

in MAIN, limit sides to Numeric, update the usage output to also incl…

…ude --sum
  • Loading branch information...
commit 40b1d5d6650fdc57701bf82e8a2d33ac9b147a49 1 parent e8cc91e
timo timo authored

Showing 1 changed file with 5 additions and 2 deletions. Show diff stats Hide diff stats

  1. +5 2 src/subs-n-sigs.pod
7 src/subs-n-sigs.pod
Source Rendered
@@ -1378,13 +1378,15 @@ a specification for command line arguments.
1378 1378 =begin programlisting
1379 1379
1380 1380 # script roll-dice.pl
1381   - sub MAIN($count = 1, :$sides = 6, Bool :$sum) {
  1381 + sub MAIN($count = 1, Numeric :$sides = 6, Bool :$sum) {
1382 1382 my @numbers = (1..$sides).roll($count);
1383 1383 say @numbers.join(' ');
1384 1384 say "sum: ", [+] @numbers if $sum;
1385 1385 }
1386 1386 # TODO: explain ranges, .pick and [+]
1387 1387 # (or reference later chapters)
  1388 + # note: [max] was already used in chapter 3, so [+] should
  1389 + # make sense to the reader already.
1388 1390
1389 1391 =end programlisting
1390 1392
@@ -1407,7 +1409,8 @@ different output if you try it.>>
1407 1409 9 14 12
1408 1410 sum: 35
1409 1411 $ perl6 roll-dice.pl --unknown-option
1410   - roll-dice.pl [--sides=value-of-sides] [count]
  1412 + Usage:
  1413 + roll-dice.pl [--sides=<Numeric>] [--sum] [<count>]
1411 1414
1412 1415 =end screen
1413 1416

0 comments on commit 40b1d5d

Please sign in to comment.
Something went wrong with that request. Please try again.