Permalink
Browse files

Fixed a trailing comma error

And unified the naming convention for mxe capitals
  • Loading branch information...
1 parent 9728a1f commit 0d1ac5299de5fcaebaf4e717cf7255ce7287d860 @initpy committed Dec 31, 2011
Showing with 4 additions and 11 deletions.
  1. +4 −11 methods.rst
View
15 methods.rst
@@ -133,20 +133,17 @@ So? Are methods applicable only for ``struct`` types? The anwser is No. In fact,
you can write methods for any *named* type that you define, that is not a
pointer:
-.. Question Why do you capitalize AgesBy below but not sliceOf? The 'random'
-.. Capitalization is confusing, perhaps it deserves a section/mention somewhere?
-
.. code-block:: go
:linenos:
package main
import "fmt"
//We define two new types
- type sliceOfints []int
+ type SliceOfints []int
type AgesByNames map[string]int
- func (s sliceOfints) sum() int {
+ func (s SliceOfints) sum() int {
sum := 0
for _, value := range s {
sum += value
@@ -167,7 +164,7 @@ pointer:
}
func main() {
- s := sliceOfints {1, 2, 3, 4, 5}
+ s := SliceOfints {1, 2, 3, 4, 5}
folks := AgesByNames {
"Bob": 36,
"Mike": 44,
@@ -218,13 +215,9 @@ Examples:
"January":31,
"February":28,
...
- "December":31
+ "December":31,
}
-.. Should likely note in the example above that the last entry does not require
-.. a comma after it. Question: Will a comma there break the compilation?
-.. Worth noting the answer.
-
See? It's actually easy, and it can be handy to give more meaning to your
code, by giving names to complicated composite -- or even simple -- types.

0 comments on commit 0d1ac52

Please sign in to comment.