From 9cd2af91f0fe01aa644166ac7b19b958a6ce5081 Mon Sep 17 00:00:00 2001 From: Pavel Tisnovsky Date: Fri, 10 Jul 2020 12:50:16 +0200 Subject: [PATCH] Example #9: Contains method for user struct stream --- .../lazy_streams/09_contains_user_structs.go | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 lesson7/lazy_streams/09_contains_user_structs.go diff --git a/lesson7/lazy_streams/09_contains_user_structs.go b/lesson7/lazy_streams/09_contains_user_structs.go new file mode 100644 index 0000000..64229bd --- /dev/null +++ b/lesson7/lazy_streams/09_contains_user_structs.go @@ -0,0 +1,38 @@ +package main + +import ( + "fmt" + "github.com/wesovilabs/koazee" +) + +type User struct { + id uint32 + name string + surname string +} + +func main() { + var users = []User{ + User{ + id: 1, + name: "Pepek", + surname: "Vyskoč"}, + User{ + id: 2, + name: "Pepek", + surname: "Vyskoč"}, + User{ + id: 3, + name: "Josef", + surname: "Vyskočil"}, + } + fmt.Println(users) + + stream := koazee.StreamOf(users) + + p1, _ := stream.Contains(User{3, "Josef", "Vyskočil"}) + fmt.Printf("contains? %v\n", p1) + + p2, _ := stream.Contains(User{4, "Josef", "Vyskočil"}) + fmt.Printf("contains? %v\n", p2) +}