Iterate Array

Hi
   I have created an array like
def checkdata(data)
      @passed_effort= data.split(':').collect! {|n| n}
      hours = @passed_effort[0]
      minutes = @passed_effort[1]
        @error_checked_value=Array.new
        if hours =~ /\D/ || minutes =~ /\D/
        @error_checked_value << 'nonnumeric'
        end
      if minutes.to_i > 59
        @error_checked_value << 'notinrange'
      end
      return @error_checked_value
end

Now how can I iterate through this array
@error_checked_value.each do |val|
     puts val
end

Is this correct?Or any other method?

Sijo

···

--
Posted via http://www.ruby-forum.com/.

Using each is the most common way to iterate an array. Is there
something more than puts-ing each value that you want to do that
caused you to ask your question?

Regards,
Craig

Hi
I have a doubt regrding .collect That is why I asked tht.Is there any
such a method?

Sijo

···

--
Posted via http://www.ruby-forum.com/.

Yes, there is. But your usage of collect does not make any sense:

xxx.collect! {|n| n}

Using #collect or #map with this block is basically a noop because
elements will be replaced by themselves.

Kind regards

robert

···

2008/5/16 Sijo Kg <sijo@maxxion.com>:

I have a doubt regrding .collect That is why I asked tht.Is there any
such a method?

--
use.inject do |as, often| as.you_can - without end