add: money type to interfaces

This commit is contained in:
Inanc Gumus
2019-08-21 23:53:47 +03:00
parent c282da3c6d
commit ce5a32ecbe
21 changed files with 113 additions and 59 deletions

View File

@ -14,14 +14,15 @@ func main() {
tetris = game{title: "tetris", price: 5}
)
var items []game
items = append(items, minecraft, tetris)
var items []*game
items = append(items, &minecraft, &tetris)
// you can attach methods to a compatible type on the fly:
my := list([]game{minecraft, tetris})
// you can call methods even on a nil value
// items -> []*game
// list -> []*game
my := list(items)
// my = nil
my.print() // or: list.print(items)
// you can call methods even on a nil value
my.print()
}