From: "Berger, Daniel" Date: 2006-07-26T23:47:37+09:00 Subject: Re: Truncate an array > -----Original Message----- > From: Aleks Kissinger [mailto:aleks0@gmail.com] > Sent: Wednesday, July 26, 2006 8:44 AM > To: ruby-talk ML > Subject: Re: Truncate an array > > > I'd thought about that too. This is bad for two reasons. > > 1. SOME_ARRAY is 'supposedly' a constant, in that ruby > complains if you assign to it more than once. If it's not constant, don't make it a constant. > 2. We didn't really truncate the array, just made a new empty one. Ok, use Array#clear then: irb(main):014:0> a = [1,2,3] => [1, 2, 3] irb(main):015:0> b = a => [1, 2, 3] irb(main):016:0> a.clear => [] irb(main):017:0> a => [] irb(main):018:0> b => [] Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.