Function signature
func Drop(item interface{}) (stream S)Arguments
| Name | Type | Description |
|---|---|---|
| item | Same type of elements in the stream | Element to be dropped from the stream |
Output
| Name | Type | Description |
|---|---|---|
| stream | koazee.S | It returns the stream modified by the current operation |
Errors
| Type | Message |
|---|---|
| err.items-nil | An element can not be dropped from a nil stream |
| err.invalid-argument | A nil value can not be dropped from a stream of non-pointers values |
| err.invalid-argument | An element whose type is %s can not be dropped from a stream of type %s |
Examples
package main
import (
"fmt"
"github.com/wesovilabs/koazee"
)
type genre int
const (
female genre = iota
male
)
type primate struct {
name string
age int
family string
genre genre
}
func newPrimate(name string, age int, family string, genre genre) *primate {
return &primate{
name: name,
age: age,
family: family,
genre: genre,
}
}
var primates = []*primate{
newPrimate("John", 15, "Capuchin", male),
newPrimate("Laura", 12, "Squirrel monkey", female),
newPrimate("Benjamin", 23, "Spider monkey", male),
newPrimate("George", 19, "Golden Lion Tamarin", male),
newPrimate("Jane", 33, "Orangutan", female),
newPrimate("Sarah", 7, "Gibbon", female),
}
func main() {
newList := koazee.StreamOf(primates).
Drop(newPrimate("Benjamin", 23, "Spider monkey", male)).
Out().
Val().([]*primate)
for _, primate := range newList {
fmt.Printf("%s was invited to the party\n", primate.name)
}
}package main
import (
"fmt"
"github.com/wesovilabs/koazee"
)
var numbers = []int{1, 3, 5, 7, 9}
func main() {
newList := koazee.Stream().
Drop(3).
With(numbers).
Out().
Val().([]int)
for _, number := range newList {
fmt.Printf("%d\n", number)
}
}