Hacker News new | ask | show | jobs
by Gazler 5029 days ago
I really like the structure of this, very readable and a great intro. I have some confusion on http://www.golang-book.com/6

It says:

Go also provides a shorter syntax for creating arrays:

x := [5]float64{ 98, 93, 77, 82, 83 }

We no longer need to specify the type because Go can figure it out. Sometimes arrays like this can get too long to fit on one line, so Go allows you to break it up like this:

However the type is specified as `float64`

3 comments

I meant you didn't need this:

var x [5]float64 = [5]float64{ 98, 93, 77, 82, 83 }

But I explained ":=" earlier so I can see how that would be confusing.

he means the type of the individual elements. Each element is of type float64, not int.
vs Java-like

float64 myfloat64array[] = new(float64[5], ...)