On 01.01.2010 17:45, Joe Buck wrote:
> Ehsan,
>
> Thanks for the help. Unfortunately I don't think that will work as it
> removes the first element in the array.

def copy_and_shift_array array
   temp_array = array # or perform a deep copy, if you are worried about
                      # about the first array's integrity.
   temp_array.each do |element|
     return element if condition_met?
   end
end

Array#shift is useful here *because* it gives you the first Array 
element in an easily accessible format (the actual Object in the Array), 
so that you can perform your checks and other magic, before storing it 
someplace else.

Note: Above code is untested, but should work, at least in principle.

(I'm always a foggy when it comes to blocks and variable assignment in 
Ruby, despite many ruby-talk discussions about scope in Ruby).

--
Phillip Gawlowski