-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add Number::pairs #51904
feat: Add Number::pairs #51904
Conversation
Hi @hotmeteor. Thank you for your pull request. I appreciate the effort. However, I believe it would be more consistent with programming language standards to set the default value of the third parameter to 0. What do you think? |
Sure, if you think so. I'm not sure what standards to compare it to though? I think from a UX perspective I'd expect it to behave as I have it. But again, if the preference is to start with zero that's fine by me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for sending in this PR. Seems very niche to me. What's your use-case? |
@ahinkle Generating values for batches, similar to what's in the docs: https://laravel.com/docs/11.x/queues#dispatching-batches |
Nice one 👍 What is the reason to call the first argument |
It represents the number you're pairing up to, though I'm sure there's other names it could have been given. I guess I thought like: Pair "by" 5, up "to" 100, "offset" by 1. Changes I could see:
|
Thanks, I'm not complaining just wanted to know more about the decision before I make a video about the feature since it wasn't that clear to me. But I get your points 👍 |
🙇 Oh cool! Ya, naming is hard and Laravel naming is always top-notch so I just want to make sure it's up to standards 😅 |
The
Number::pairs()
method provides the ability to "split" a number into pairs of min/max values. It's sort of likesliding
, except the method will determine the values for you.The method can create pairs of integers or floats.
Examples:
Thanks!