godash icon indicating copy to clipboard operation
godash copied to clipboard

Add support for channels in godash.Reduce

Open dineshba opened this issue 5 years ago • 1 comments

API

input := make(chan int)
var output int

go func() {
    for i := 0; i <= 5; i++ {
        input <- i				
    }
    close(input)
}()

godash.Reduce(input, &output, func(sum , element int) int {
  return sum + element
})

fmt.Println(output)

// Output: 15

dineshba avatar Oct 14 '19 10:10 dineshba

@dineshba I will work on this enhancement

snaveen avatar Oct 14 '19 11:10 snaveen