Robert Klemme
11/12/2007 3:09:00 PM
2007/11/12, Luca Roma <roma@nerto.it>:
> i have 2 arrays of objects: dates and places
>
> dates have attribute place_id
> and places have id
>
> I must to selezionate all places that have id in array of objects dates.
>
> dates.select{|obj| obj.place_id in places[].id }
>
> How i can replace "in places[].id " to works it?
Create a Set of place ids and test against that when selecting.
Alternative use #any? on places to test for a place with the current
date's place_id but this is very inefficient.
Cheers
robert
--
use.inject do |as, often| as.you_can - without end