peterbe / govspy

Go vs. Python
http://govspy.peterbe.com
116 stars 14 forks source link

Go Methods #6

Open tovare opened 6 years ago

tovare commented 6 years ago

Since many languages use this as a reserved word. Maybe it would be even clearer to use something like p1, p2 or A,B ?

func (p1 Point) distance(p2 Point) float64 { return math.Sqrt(p1.xp2.x + p1.yp2.y) }

peterbe commented 6 years ago

What's the reserved word? You mean the word this? Isn't that a JavaScript thing?

tovare commented 6 years ago

Right, not really directly related to the comparison ... its javascript, java :-)