Practicing methods

This commit is contained in:
raul 2024-04-15 08:30:10 +02:00
parent 3921e103a5
commit 7c73e03d60
2 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,3 @@
module methods-2
go 1.22.2

View File

@ -0,0 +1,18 @@
package main
import (
"fmt"
)
type Nums struct {
X float64
}
func (n Nums) Multiply() float64 {
return n.X * 2
}
func main() {
newnumber := Nums{10}
fmt.Println(newnumber.Multiply())
}