Collections: add arg for formatting decimal point #44609
Unanswered
hiro-lapis
asked this question in
Ideas
Replies: 1 comment
-
Why don't just $points = [3, 3, 6, 7, 2, 5];
echo round(collect($points)->avg(), 1); // 4.3
echo ceil(collect($points)->avg()); // 5
echo floor(($points)->avg()); // 5 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In current, Collections
avg()
is like this. It`s alway return native float value,Sometimes we want formatted value, need format out of this method.
I think It would be better to include format process in avg(), in a view of encapsuling get average process.
So My suggestion of implementation:
sample spec of suggestion
Beta Was this translation helpful? Give feedback.
All reactions