user
Loop through and print each element in a collection in order.

Use your language's "for each" loop if it has one, otherwise iterate through the collection in order with some other loop.

Related tasks

* Loop over multiple arrays simultaneously
* Loops/Break
* Loops/Continue
* Loops/Do-while
* Loops/Downward for
* Loops/For
* Loops/For with a specified step
* Loops/Foreach
* Loops/Increment loop index within loop body
* Loops/Infinite
* Loops/N plus one half
* Loops/Nested
* Loops/While
* Loops/with multiple ranges
* Loops/Wrong ranges
assistant
(formerly Perl 6)

**Works with**: Rakudo version 2015.10-40

```
say $_ for @collection;
```

Raku leaves off the each from foreach, leaving us with for instead. The variable $\_ refers to the current element, unless you assign a name to it using ->.

```
for @collection -> $currentElement { say $currentElement; }
```

Raku will do it's best to put the topic at the right spot.

```
.say for @collection;
for @collection { .say };
```

Iteration can also be done with hyperoperators. In this case it's a candidate for autothreading and as such, execution order may vary. The resulting list will be in order.

```
@collection>>.say;
@collection>>.=&infix:<+>(2); # increment each element by 2
```