pluck :: Enumerable |
Since it avoids the cost of a lexical closure over an anonymous function (like you would do with collect), this performs much better. Perhaps more importantly, it definitely makes for more concise and more readable source code.
Examples
['hello', 'world', 'this', 'is', 'nice'].pluck('length') // -> [5, 5, 4, 3, 4]
document.getElementsByClassName('superfluous').pluck('tagName').sort().uniq() // -> sorted list of unique canonical tag names for elements with this // specific CSS class...
See also
The invoke method does much the same thing for method invoking.
Enumerable: invoke |
Prototype API 1.5.0 - prototypejs.org