Skip to content

Conversation

DianaDenpa
Copy link
Contributor

@DianaDenpa DianaDenpa commented May 2, 2018

The collection "avg()" method counts null as a value to divide by, resulting in an inaccurate calculation.

Examples:

  • Before
$c = new Collection([1, 2, 3, 4, 5, null])
$c->avg(); // 2,5
  • After
$c = new Collection([1, 2, 3, 4, 5, null])
$c->avg(); // 3

This PR is a follow up to #23909

@DianaDenpa DianaDenpa changed the title Collection avg() should ignore null [5.7] Collection avg() should ignore null May 2, 2018
@taylorotwell taylorotwell merged commit 69dd3b8 into laravel:master May 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants