Tuesday, December 29, 2009

[Rails] Re: missed elements in array

Frederick Cheung wrote:
> On Dec 29, 2:21�pm, LeonS <leonard.stellbr...@gmail.com> wrote:
>> Hi,
>> i despair in case of an array.
>> I'll take some data into an array, but when i iterate the array some
>> elements of the array seems to be missed, but the missing element are
>> displayed in the view.
>> I'm using the Plugin Rails_Authorization.
>>
>
> You're deleting from the array as you are iterating over it - don't do
> that.

Yep. A common mistake when iterating arrays. One solution is to build a
new array containing the objects you want, rather than deleting objects
that you don't want. There may be better approaches that might use less
memory though.
--
Posted via http://www.ruby-forum.com/.

--

You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate