On 05.03.2007 17:21, Josselin wrote:
> On 2007-03-05 17:00:58 +0100, Robert Klemme <shortcutter / googlemail.com> 
> said:
> 
>> On 05.03.2007 16:37, hemant wrote:
>>> On 3/5/07, Josselin <josselin / wanadoo.fr> wrote:
>>>> I am trying to nest 2 blocks, it's wrong but but I cannot find why ..
>>>> need some help.. I get only one resulting item
>>>>
>>>> I get  info in geocodes Array (3 items) , need to get some of them into
>>>> 'places' another Array
>>>>
>>>>       places = [ {:search => adresse}]
>>>>
>>>>       geocodes.each {  | geocode |
>>>>            places.collect { | place |
>>>>                 place[:address] = geocode[:address]
>>>>                 place[:latitude] = geocode[:latitude]
>>>>                 place[:longitude] = geocode[:longitude]
>>>>           }
>>>>       }
>>>>
>>>> geocodes.nitems => 3
>>>
>>> #collect doesn't modify the existing Enumerable  and normally returns
>>> a Enumerable/Array.
>>> In other words, your inner block doesn't modify places array at all.
>>
>> No need for collect or collect! at all since he is modifying the 
>> Hash(es) inside places.  And since places contains only 1 element it 
>> still does so after the iteration.  Josselin, what do you expect to get?
>>
>> Kind regards
>>
>>     robert
> 
> Thanks  for your comments..
> 
> well I expect to get 3 items (one for each geocodes item)
> where   places[i][:longitude] = geocodes[i][:longitude], .....
> I know that I could do an iteration (as in C) but I tried to do it 
> without using an indexation ...
> 
> places[i]
> => {:longitude=> geocodes[i][longitude], 
> :latitude=>geocodes[i][longitude], :address=>geocodes[i][address]}
> 
> joss
> 
> 
result = geocodes.map do |geocode|
   {:search => adresse, :address => geocode[:address], ...}
end

	robert