Skip to content

Commit

Permalink
Example #9: Contains method for user struct stream
Browse files Browse the repository at this point in the history
  • Loading branch information
tisnik committed Jul 10, 2020
1 parent 5c17b81 commit 9cd2af9
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions lesson7/lazy_streams/09_contains_user_structs.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit 9cd2af9

Please sign in to comment.