A C extension alternative to using flatten.compact or flatten.map. Slight performance improvement (just a constant factor better) than the common idioms, with exactly the same memory performance.
See this blog post for the background and a chart of memory performance.
In addition, collapse makes two other slightly different choices from core Ruby's flatten. 1. Attempting to flatten a recursive Array will error normally. collapse just drops the recursive reference, and continues on its merry way. 2. collapse doesn't accept a level argument. It's all or nothing.
Array#collapse alternatives and similar gems
Based on the "Core Extensions" category
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest. Visit our partner's website for more details.
Do you think we are missing an alternative of Array#collapse or a related project?