From 1495007ab2f89cd6e467e8be592198900ffca36b Mon Sep 17 00:00:00 2001 From: Inanc Gumus Date: Mon, 9 Sep 2019 20:48:33 +0300 Subject: [PATCH] add: interface comparison example --- interfaces/04-interfaces/main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/interfaces/04-interfaces/main.go b/interfaces/04-interfaces/main.go index 755f553..841379d 100644 --- a/interfaces/04-interfaces/main.go +++ b/interfaces/04-interfaces/main.go @@ -7,6 +7,8 @@ package main +import "fmt" + func main() { var ( mobydick = book{title: "moby dick", price: 10} @@ -24,4 +26,8 @@ func main() { var store list store = append(store, &minecraft, &tetris, mobydick, rubik) store.print() + + // interface values are comparable + fmt.Println(store[0] == &minecraft) + fmt.Println(store[3] == rubik) }