go_sandbox/internal/learning/methods.go
2024-11-02 14:07:18 +03:00

30 lines
418 B
Go

package learning
import (
"fmt"
"math"
)
type MethodsVertex struct {
X, Y float64
}
func (v MethodsVertex) Abs() float64 {
return math.Sqrt(v.X*v.X + v.Y*v.Y)
}
func MethodsLearning() {
v := MethodsVertex{3, 5}
fmt.Println(v.Abs())
}
func (v MethodsVertex) Scale(f float64) {
v.X = v.X * f
v.Y = v.Y * f
}
func PointersMethodsLearning() {
v := MethodsVertex{3,4}
v.Scale(10)
fmt.Println(v.Abs())
}