-
Notifications
You must be signed in to change notification settings - Fork 42
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
get_each function #88
Conversation
…e in the case it does not exist of each item in a $coll
…function Lambdish\Phunctional\_get_values_from_key expects string, int|string given.
Could you create the documentation for it? 😊🙏 |
Oooppsss sorry!!! yes I could, I forgot to do that.😔 |
docs/functions/get_each.md
Outdated
|
||
return get_each('email', $users); | ||
|
||
// => ['mike@example.com', 'john@example.com', null] |
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.
Could we change this behaviour to "if the key doesn't exists it doesn't return anything".
// => ['mike@example.com', 'john@example.com', null] | |
// => ['mike@example.com', 'john@example.com'] |
I'm thinking in cases and I believe this behaviour would be more useful to people. What do you think?
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.
I was thinking about that several times and finally I thought that output array had to have as many elements as input array and put default value in each element which didn't have the key but I am not sure it is the best solution, maybe you are right.
I am going to change the behavior of the function but what would you do with the default value? would you remove it and return and empty array if any element contains the key? I think it would be the best solution.
What is the procedure to follow when the intallation of dependecies fails? |
@joucogi it was a GitHub bug, I just re-ran all the tests 😬 Thanks for the function!! |
👍🏻 |
get_each function returns an array with the values or a $default value in the case it does not exist of each item in a $coll