|
Matt Harden |
at Oct 17, 2014 at 1:55 am
|
⇧ |
| |
I agree with Jan, and others in this thread. Clearly the Go authors knew
about the "in" keyword in other languages, and specifically chose not to
include it. Range does the job better, without (much) special syntax. While
I missed "in" at first, now range seems perfectly natural. One thing that
hasn't been mentioned is how range enables capturing key, value pairs using
the same multiple-return-value syntax used elsewhere in the language,
unlike other languages I will refrain from mentioning, which need
additional functions like keys(), values(), items(), iterkeys(), etc. to
enable the same functionality.
On Thu, Oct 16, 2014 at 10:49 AM, Jan Mercl wrote:On Thu, Oct 16, 2014 at 12:17 PM, wrote:
I would like to have the keyword "in" as syntactic sugar for ":= range".
So that we could write:
for index, val in slice {
}
instead of
for index, val := range slice {
}
The existing syntax allows to either create new, loop scoped variables
(with :=) or reuse existing, outer scoped ones and that's an important
feature. The proposal seems to not consider it.
-j
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit
https://groups.google.com/d/optout. --
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit
https://groups.google.com/d/optout.