Generalize for-each loops
Closed this issue · 0 comments
lhmouse commented
At the moment for-each loops look like
for(each key, value -> container)
// ...
There are two issues:
- Very often we only want
value
and notkey
, but we can't omit it. key
andvalue
are separated by a comma. We use a colon or equals sign elsewhere.
The proposal is to change
for-complement-range ::=
"each" identifier "," identifier "->" expression ")" statement
to
for-complement-range ::=
"each" identifier ( ( "," | ":" | "=" ) identifier ) ? "->" expression ")" statement
If the second identifier is omitted, then there will not be a key variable.