-
Notifications
You must be signed in to change notification settings - Fork 73
Flattening function for arrays #31
Conversation
src/ArrayUtils.php
Outdated
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.
move fqcn to use statement
Fixed. |
What is the use case for this? Looking at the test cases, this is not something I've ever really desired, which is why I'd like to see what use cases there are before we consider adding it. It seems like something where different developers might have different expectations, to be honest. |
@akond to add on a bit more context from @weierophinney specifically flattening an array means many things to many people. The implementation is a bit confusing at first but I can see where you are going with it but the use case is not general. There are likely several different possibilities for flattening where i might expect the leaf keys, the leaf values, an associative array of all of the leaves, i might also expect it to combine the keys to provide no-loss, etc. What other large frameworks or languages have you seen implement something similar? |
I have no experience with any other large frameworks, and yes, it is not as commonly used as merginig, but I occasionally come across this task of flattening arrays, so I though it would be fine to have it in the component, so I dont need to reinvent this function once again. |
@akond no we accept far more than "general" that comment is more inline that the function has a general name such as "flatten" which the meaning could be quite different depending on what the developer is looking for. The hard part about a pull request like this one, is that if we do go the route of having a flatten method, we need to come up with the use cases and implement those that other developers might think of when they think of flattening an array. For instance ruby has a depth when it flattens: http://apidock.com/ruby/Array/flatten All in all, there are a ton of things out there on the subject and the use cases vary in extremes and at that point the flatten method might more or less have to take a flattening strategy vs. a singular implement. |
I can see now that this thing does not fit very well. So I think I'm gonna close this down. |
No description provided.