Re: Truncate an array

complains if you assign to it more than once.
If it’s not constant, don’t make it a constant.

  1. 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
=> []



This communication is the property of Qwest and may contain confidential
privileged information. Unauthorized use of this communication is
prohibited and may be unlawful. If you have received this communication
in error, please immediately notify the sender by reply e-mail and
all copies of the communication and any attachments.

ah, thats the one.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs