I’m not sure if C has been directly mentioned. I started with C so
iteration is just a nice shortcut to me. Assuming you’ve always had
collection iteration available an explanation is the for loop can make the
useful pattern of indexing into an array up to the length of the array
using an index variable.
s := [5]int{0, 1, 2, 3, 4}
// this C-style iteration prints 12345
for i := 0; i < len(s); i++ {
fmt.Print(s[i]+1)
}
Coming from C it makes sense to me to combine all looping, including
collection iteration, into one keyword. For, while, and do-while all look
the same to me.
Matt
On Wednesday, May 9, 2018 at 4:26:44 PM UTC-5, Hugh Fisher wrote:
>
>
>
> On Thursday, May 10, 2018 at 4:20:41 AM UTC+10, Marc wrote:
>>
>> I'm still not convinced this topic is not some kind of elaborate joke.
>>
>
> It's certainly diverged from my original post, which is why I'm staying
> quiet.
>
> cheers,
> Hugh Fisher
>
>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.