diff --git a/tour-of-go/methods-2/go.mod b/tour-of-go/methods-2/go.mod new file mode 100644 index 0000000..e6d3348 --- /dev/null +++ b/tour-of-go/methods-2/go.mod @@ -0,0 +1,3 @@ +module methods-2 + +go 1.22.2 diff --git a/tour-of-go/methods-2/main.go b/tour-of-go/methods-2/main.go new file mode 100644 index 0000000..1e63dd1 --- /dev/null +++ b/tour-of-go/methods-2/main.go @@ -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()) +}