Skip to content
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

Merged
merged 4 commits into from
Sep 18, 2020
Merged

get_each function #88

merged 4 commits into from
Sep 18, 2020

Conversation

joucogi
Copy link
Contributor

@joucogi joucogi commented Sep 8, 2020

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

…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.
@rgomezcasas
Copy link
Member

Could you create the documentation for it? 😊🙏

@joucogi
Copy link
Contributor Author

joucogi commented Sep 8, 2020

Oooppsss sorry!!! yes I could, I forgot to do that.😔


return get_each('email', $users);

// => ['mike@example.com', 'john@example.com', null]
Copy link
Member

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".

Suggested change
// => ['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?

Copy link
Contributor Author

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.

@joucogi
Copy link
Contributor Author

joucogi commented Sep 17, 2020

What is the procedure to follow when the intallation of dependecies fails?

@rgomezcasas
Copy link
Member

@joucogi it was a GitHub bug, I just re-ran all the tests 😬

Thanks for the function!!

@rgomezcasas rgomezcasas merged commit ed3482e into Lambdish:master Sep 18, 2020
@rgomezcasas
Copy link
Member

@joucogi joucogi deleted the get_each-function branch September 18, 2020 07:28
@joucogi
Copy link
Contributor Author

joucogi commented Sep 18, 2020

@joucogi it was a GitHub bug, I just re-ran all the tests 😬

Thanks for the function!!

👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants