Skip to content

Commit ac5f0a4

Browse files
committed
Merge branch 'master' of github.com:perl6/doc
2 parents 2460f90 + 565c4d2 commit ac5f0a4

File tree

4 files changed

+39
-7
lines changed

4 files changed

+39
-7
lines changed

lib/Language/concurrency.pod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ will be kept (and consequently will evaluate to True in a boolean context,)
371371
when the channel is closed.
372372
373373
Because looping over a channel in this manner is a common pattern there is
374-
a simpler fumctional syntax to do this:
374+
a simpler functional syntax to do this:
375375
376376
my $channel = Channel.new;
377377

lib/Language/operators.pod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,9 @@ In most cases, a dot may be placed before a postfix or postcircumfix:
265265
@a.[1, 2, 3]; # Same
266266
267267
This can be useful for visual clarity or brevity. For example, if an object's
268-
attribute is a function, putting a pair of paretheses after the attribute name
269-
will become part of the method call. So either two pairs of paretheses must be
270-
used, or a dot has to come before the parentheses to seperate it from the method
268+
attribute is a function, putting a pair of parentheses after the attribute name
269+
will become part of the method call. So either two pairs of parentheses must be
270+
used, or a dot has to come before the parentheses to separate it from the method
271271
call.
272272
273273
class Operation {

lib/Language/syntax.pod

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,26 @@ Long forms with explicit values:
328328
:thing['some', 'values'] # same as thing => ['some', 'values']
329329
:thing{a => 'b'} # same as thing => { a => 'b' }
330330
331-
=begin comment
332-
333331
=head3 Array literals
334332
335-
TODO
333+
A pair of square brackets can surround an expression to for an
334+
itmized L<Array|/type/Array> literal; typically there is a comma-delimited list
335+
inside:
336+
337+
say ['a', 'b', 42].join(' '); # a b 42
338+
# ^^^^^^^^^^^^^^ Array constructor
339+
340+
The array constructor flattens non-itemized arrays and lists, but not itemized
341+
arrays themselves:
342+
343+
my @a = 1, 2;
344+
# flattens:
345+
say [@a, 3, 4].elems; # 4
346+
347+
# does not flatten:
348+
say [[@a], [3, 4]].elems; # 2
349+
350+
=begin comment
336351
337352
=head3 Hash literals
338353

lib/Type/List.pod

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,23 @@ Combining multiple cycles and C<:partial> also works:
574574
say ('a'..'h').rotor(1 => 1, 3 => -1, :partial).join('|');
575575
# a|c d e|e|g h
576576
577+
Note that assigning the list of lists returned from C<rotor> to a variable
578+
will flatten to an C<Array>:
579+
580+
my @maybe_lol = ('a'..'h').rotor(2 => 1);
581+
@maybe_lol.perl.say; #-> ["a", "b", "d", "e", "g", "h"]<>
582+
583+
Which probably isn't what one wanted, since the C<rotor>-ed output looks
584+
like this:
585+
586+
say ('a'..'h').rotor(2 => 1).perl; #-> (("a", "b"), ("d", "e"), ("g", "h"))
587+
588+
To force a C<List> of C<List>s to be returned, I<bind> the output instead of
589+
assigning it:
590+
591+
my @really_lol := ('a'..'h').rotor(2 => 1);
592+
@really_lol.perl.say; #-> (("a", "b"), ("d", "e"), ("g", "h"))
593+
577594
=head2 routine zip
578595
579596
sub zip(List:D:, List:D:, ...) returns List:D

0 commit comments

Comments
 (0)