thecoderartist / go-tour

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

"Type conversions": maybe change example to match the point the text is trying to make about explicit conversions #174

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Text says: "Unlike in C, in Go assignment between items of different type 
requires an explicit conversion. Try removing the float64 or int conversions in 
the example and see what happens."

But the example says:

    var x, y int = 3, 4
    var f float64 = math.Sqrt(float64(3*3 + 4*4))

so removing the float64 conversion:

    var x, y int = 3, 4
    var f float64 = math.Sqrt(3*3 + 4*4)

still gives a working program. It might make more sense if the example were:

    var x, y int = 3, 4
    var f float64 = math.Sqrt(float64(x*x + y*y))

so that the float64 conversion was actually required to make the program work.

Original issue reported on code.google.com by sjnickerson@google.com on 14 May 2014 at 12:45