From 7c73e03d60726bf6074a0a7f4872d7d69c09f98f Mon Sep 17 00:00:00 2001 From: raul Date: Mon, 15 Apr 2024 08:30:10 +0200 Subject: [PATCH] Practicing methods --- tour-of-go/methods-2/go.mod | 3 +++ tour-of-go/methods-2/main.go | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tour-of-go/methods-2/go.mod create mode 100644 tour-of-go/methods-2/main.go 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()) +}