Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Conversation

akond
Copy link

@akond akond commented Oct 8, 2015

No description provided.

Copy link
Contributor

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

@akond
Copy link
Author

akond commented Oct 12, 2015

Fixed.

@weierophinney
Copy link
Member

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.

@mwillbanks
Copy link
Contributor

@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?

@akond
Copy link
Author

akond commented Oct 15, 2015

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.
I agree, that the implementation is indeed one-sided, and probably needs some more elaboration. It didn't occur to me that keys might be of value.
So you accept only general functions?
The use case is coming tomorrow. It is in the office.

@mwillbanks
Copy link
Contributor

@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
underscore.js and lodash have a shallow option: http://underscorejs.org/#flatten
cakephp has an option to flatten by leveraging keys: http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::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.

@akond
Copy link
Author

akond commented Oct 16, 2015

I can see now that this thing does not fit very well. So I think I'm gonna close this down.

@akond akond closed this Oct 16, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants