criswxart / go-tour

Automatically exported from code.google.com/p/go-tour
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Fix assignment syntax in "Mutating maps" #169

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Please merge : 

https://code.google.com/r/chaumond-go-tour/source/detail?r=b1c4eae404f876ee96801
687e4f1a8286b1b9941

Original issue reported on code.google.com by chaum...@gmail.com on 9 Dec 2013 at 2:34

GoogleCodeExporter commented 8 years ago

Original comment by a...@golang.org on 12 Dec 2013 at 2:26

GoogleCodeExporter commented 8 years ago
Actually, no. Not accepted because this demonstrates an assignment, not a 
declaration.

Original comment by a...@golang.org on 12 Dec 2013 at 2:27

GoogleCodeExporter commented 8 years ago
The textual example of presence detection does not work.  The code example, 
which does work, uses := and not =.  

Switching to = in the code example breaks the example.  I'm unclear as to 
whether WontFix closure of this means to imply that the tour should show 
breaking examples.  Are we meant to mentally translate from "=" in the text to 
":=" in the code?

Original comment by mykel.al...@gmail.com on 20 Jul 2014 at 1:27

GoogleCodeExporter commented 8 years ago
Yes, as a Go programmer you need to know the distinction between := and = and 
when to use them both.

Original comment by a...@golang.org on 22 Jul 2014 at 1:40

GoogleCodeExporter commented 8 years ago
I'm aware of the differences between the two.  The delta between the tutorial 
text and the running code includes an instance of the difference between 
assignment and declaration, which can be confusing to the tutorial's target 
audience (i.e. people still learning Go).  

This difference exists elsewhere, but I've observed this confusion most often 
on the Mutating Maps page while assisting people through the tutorial.  
Specifically, there has been more than one instance of a concern that the test 
assignment might have some special syntax.

The given patch doesn't really address this, simply forcing the text to conform 
to the code format.

However, I've decided to take this as an opportunity to reinforce both the 
short var declaration as well as the lack of special syntax.  I presented 'var 
elem, ok = m[key]' as well as assigning to previously declared variables and it 
cleared the confusion to at least a couple of the people learning using the 
tutorial.

Original comment by mykel.al...@gmail.com on 22 Jul 2014 at 12:47