Practicing methods
This commit is contained in:
parent
3921e103a5
commit
7c73e03d60
|
@ -0,0 +1,3 @@
|
|||
module methods-2
|
||||
|
||||
go 1.22.2
|
|
@ -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())
|
||||
}
|
Loading…
Reference in New Issue