From: Max Williams Date: 2007-11-13T00:11:50+09:00 Subject: Re: array select Luca Roma wrote: > 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? > Thanks You could use Array#collect, which creates a new array out of another array, taking a block of code that processes an element of the old array and spits out something to go into the new array. so, places[].id would be places.collect{ |place| place.id} You can then ask if obj.place_id is in this, as follows: dates.select{ |obj| places.collect{ |place| place.id}.include?(obj.place_id) } I think that's what you're after (i'm not exactly sure from your question, sorry). -- Posted via http://www.ruby-forum.com/.