Example #1
0
func (t *Totaler) Consume(s functional.Stream) {
	var entry Entry
	for s.Next(&entry) {
		if t.Income {
			if entry.Amount < 0 {
				t.Total -= entry.Amount
			}
		} else {
			if entry.Amount > 0 {
				t.Total += entry.Amount
			}
		}
	}
}
Example #2
0
func (p Printer) Consume(s functional.Stream) {
	var entry Entry
	for s.Next(&entry) {
		fmt.Println(&entry)
	}
}