On 23/08/07, Ben Newman <[EMAIL PROTECTED]> wrote:
> See Enumerable#select:
>
> > [1, 'a', 2, {}].select(function(n) { return typeof n == 'number' })
> [1, 2]
>
> The name "select" is from Ruby, like most odd things in Prototype :)
>
> On Aug 23, 2:32 am, "Richard Quadling" <[EMAIL PROTECTED]>
> wrote:
> > Hi.
> >
> > I've just created a small function to filter an array. Sort of the
> > reverse of each+without.
> >
> > /*
> > Version 1.0.0 - Thursday, 23 August 2007 10:25 am
> > */
> >
> > Object.extend (
> > Array.prototype, {
> > /***************************************/
> > /* Allow inline filtering of an array. */
> > /***************************************/
> > filter: function(f_Filter) {
> > var a_Return = [];
> > for (var i = 0, length = this.length; i < length;
> > ++i)
> > if (f_Filter(this[i]))
> > a_Return.push(this[i]);
> > return a_Return;
> > }
> > }
> > );
> >
> > Usage :
> >
> > a_Array.filter(function(item){return true/false;}).chain().chain();
> >
> > With that 2 questions.
> >
> > 1 - Have I made any REALLY obvious mistakes.
> > 2 - How do I submit this to the core?
> >
> > Richard
Which is actually an alias for findAll(). Doh! Thank you.
--
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---