Skip to content

Commit

Permalink
Add desctiption about implicit slicing on foreach statement
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Jul 23, 2015
1 parent 466c813 commit 2759d7b
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion statement.dd
Expand Up @@ -687,7 +687,26 @@ $(H4 $(LEGACY_LNAME2 foreach_with_ranges, foreach-with-ranges, Foreach over Stru
$(P If the aggregate expression is a struct or class object, but the
$(D opApply) for $(D foreach), or $(D opApplyReverse) $(D foreach_reverse) do not exist,
then iteration over struct and class objects can be done with range primitives.
For $(D foreach), this means the following properties and methods must
)

$(P First, the $(I ForeachAggregate) will be checked for a slice operator
$(D []) to try to get a range object from non-iterable containera:
)

---
foreach (e; container) { ... }
---

$(P is translates to:)

---
foreach (e; container[]) { ... }
---

$(P if possible.
)

$(P For $(D foreach), this means the following properties and methods must
be defined:
)

Expand Down

0 comments on commit 2759d7b

Please sign in to comment.