refactor: stringer interface
This commit is contained in:
		| @@ -11,9 +11,9 @@ import "fmt" | ||||
|  | ||||
| func main() { | ||||
| 	store := list{ | ||||
| 		&book{product{"moby dick", 10}, 118281600}, | ||||
| 		&book{product{"odyssey", 15}, "733622400"}, | ||||
| 		&book{product{"hobbit", 25}, nil}, | ||||
| 		&book{product{"moby dick", 10}, toTimestamp(118281600)}, | ||||
| 		&book{product{"odyssey", 15}, toTimestamp("733622400")}, | ||||
| 		&book{product{"hobbit", 25}, unknown}, | ||||
| 		&puzzle{product{"rubik's cube", 5}}, | ||||
| 		&game{product{"minecraft", 20}}, | ||||
| 		&game{product{"tetris", 5}}, | ||||
| @@ -26,4 +26,8 @@ func main() { | ||||
| 	// but the Print function can print it. | ||||
| 	// it's because, the list satisfies the stringer. | ||||
| 	fmt.Print(store) | ||||
|  | ||||
| 	// timestamp is useful even if it's zero. | ||||
| 	var ts timestamp | ||||
| 	fmt.Println(ts) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user