Skip to content

Commit 15957e1

Browse files
committed
Update doc on List.head/tail
1 parent 229ec9b commit 15957e1

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

doc/Type/List.pod

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,37 +341,44 @@ Examples:
341341
342342
Defined as:
343343
344-
multi method head(List:D: Int:D $number) returns Seq:D
344+
multi method head(List:D: Int(Cool) $number = 1) returns Seq:D
345345
346346
Usage:
347347
348+
LIST.head
348349
LIST.head(NUMBER)
349350
350351
Returns the B<first> NUMBER items of the list. Returns an empty list if
351-
NUMBER <= 0.
352+
NUMBER <= 0. Defaults to the first element seen if no NUMBER specified.
352353
353354
Examples:
354355
355356
say ^10 .head(5) # 0 1 2 3 4
356357
say ^Inf .head(5) # 0 1 2 3 4
358+
say ^10 .head # 0
359+
say ^Inf .head # 0
357360
358361
=head2 method tail
359362
360363
Defined as:
361364
362-
multi method tail(List:D: Int:D $number) returns Seq:D
365+
multi method tail(List:D: Int(Cool) $number = 1) returns Seq:D
363366
364367
Usage:
365368
369+
LIST.tail
366370
LIST.tail(NUMBER)
367371
368372
Returns the B<last> NUMBER items of the list. Returns an empty list if
369-
NUMBER <= 0. Throws an exception if the list is lazy.
373+
NUMBER <= 0. Defaults to the last element seen if no NUMBER specified.
374+
Throws an exception if the list is lazy.
370375
371376
Examples:
372377
373378
say ^10 .tail(5) # 5 6 7 8 9
374379
say ^Inf .tail(5) # Cannot tail a lazy list
380+
say ^10 .tail # 9
381+
say ^Inf .tail # Cannot tail a lazy list
375382
376383
=head2 routine classify
377384

0 commit comments

Comments
 (0)