This project is archived and is in readonly mode.
Add in place versions of compact, uniq, flatten to Array.prototype
Reported by matthuhiggins | April 29th, 2008 @ 07:13 PM
Given that prototype is modeled after Ruby, it seems like the in place '!' versions of these functions are missing. Since Array.prototype.reverse already takes an optional 'inline' parameter, it seems inconsistent that these other functions do not support it.
Let me try to hand type a rough version in this little text box:
_compact: function() {
var index = 0, last = this.length - 1;
while(index <= last) {
if (this[last] == null) {
last--;
} else if (this[index] == null) {
this[index++] = this[last--];
} else {
index++;
}
}
this.length = last + 1;
return this;
},
compact: function(inline) {
return (inline !== false ? this : this.toArray())._compact();
}
...
(Apologies if I am bringing up an old subject that has already been shot down.)
Comments and changes to this ticket
-
Frederick Cheung April 29th, 2008 @ 07:42 PM
This should be on the prototype light house (http://prototype.lighthouseapp.com/)
-
matthuhiggins April 29th, 2008 @ 08:28 PM
I added this ticket over at prototype.lighthouse. I do not have privileges to close this one.
-
DHH April 30th, 2008 @ 09:40 PM
- State changed from new to resolved
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>