Skip to content

Commit 8dd339e

Browse files
author
Jan-Olof Hendig
committed
Added some more code examples plus some sundry stuff
1 parent 39b1226 commit 8dd339e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

doc/Type/Range.pod6

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,18 @@ Returns the number of elements in the range, e.g. when being iterated over,
175175
or when used as a C<List>. Returns Inf if either end point was specified
176176
as C<Inf> or C<*>.
177177
178+
say (1..5).elems; # 5
179+
say (1^..^5).elems; # 3
180+
178181
=head2 method list
179182
180183
method list(Range:D:) returns List:D
181184
182185
Generates the list of elements that the range represents.
183186
187+
say (1..5).list; # (1 2 3 4 5)
188+
say (1^..^5).list; # (2 3 4)
189+
184190
=head2 method flat
185191
186192
method flat(Range:D:) returns List:D
@@ -207,9 +213,9 @@ by not actually generating the list if it is not necessary.
207213
208214
multi method sum() returns Numeric:D
209215
210-
Returns the sum of all elements in the Range. Throws X::Str::Numeric if an element can not be coerced into Numeric.
216+
Returns the sum of all elements in the Range. Throws L<X::Str::Numeric> if an element can not be coerced into Numeric.
211217
212-
(1..10).sum #55
218+
(1..10).sum # 55
213219
214220
=head2 method reverse
215221

0 commit comments

Comments
 (0)