collections icon indicating copy to clipboard operation
collections copied to clipboard

Add "avg" method

Open marcuspoehls opened this issue 7 years ago • 4 comments

The collection.avg() method returns the average of all collection items:

Example

await Collect([1, 2, 3, 4])
  .avg()

// 2,5

Bonus Create an alias method .average() that calls .avg() internally.

marcuspoehls avatar Oct 07 '19 12:10 marcuspoehls

Hi, I can work on this.

dragonstin avatar Oct 07 '19 13:10 dragonstin

@fernandadagostin Hey Fernanda, thank you for your support! Someone else already submitted a PR #14

This PR requires some additional work. I'll ask Dominik (@StuckD) for refinements. If he's willing to change the code, I'll favor his PR when merging. Sorry.

If you're still interested in a contribution, I'd love to see a "max" method in the collections package. I'll go ahead and create an issue and mention you. Is that ok for you?

marcuspoehls avatar Oct 07 '19 14:10 marcuspoehls

That's perfect!

dragonstin avatar Oct 07 '19 14:10 dragonstin

@fernandadagostin Awesome, thank you!

marcuspoehls avatar Oct 07 '19 14:10 marcuspoehls