Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #6338 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

[PATCH] clone() method for Arrays

Reported by: Tobie Assigned to: sam
Priority: normal Milestone: 1.x
Component: Prototype Version:
Severity: normal Keywords:
Cc:

Description

Best explained by the following:

var a = [1, 2, 3];
var b = a;
b.reverse();
alert(a) // -> [3, 2, 1]

var a = [1, 2, 3];
var b = a.clone();
b.reverse();
alert(a) // -> [1, 2, 3]

or my blog post on the subject: http://tobielangel.com/bytesandpieces/2006/08/11/extending-prototype-cloning-arrays/

Tests attached.

Attachments

array.diff (346 bytes) - added by Tobie on 10/03/06 04:49:12.
the js
array.html.diff (0.7 kB) - added by Tobie on 10/03/06 04:50:13.
the tests

Change History

10/03/06 04:49:12 changed by Tobie

  • attachment array.diff added.

the js

10/03/06 04:50:13 changed by Tobie

  • attachment array.html.diff added.

the tests

10/13/06 12:39:10 changed by madrobby

  • status changed from new to closed.
  • resolution set to fixed.

(In [5294]) Prototype: Add clone() method to arrays, fixes #6338 [Tobie Langel]