From: Lyle Johnson Date: 2010-04-22T22:27:53+09:00 Subject: Re: If-Else within a loop going through array elements... On Thu, Apr 22, 2010 at 8:12 AM, Saeed Bhuta wrote: > I'm having problems with a if-else statement within a loop which cycles > through an array, the code; >    if i == 1 >      puts "if statement is working for first condition" >      serviceDetailsHash["direction"] = directionArray[0].inner_html > >    else if i == 2 >      puts "if statement is working for second condition" >      serviceDetailsHash["direction"] = directionArray[1].inner_html >    end Replace "else if" with "elsif", i.e. elsif i == 2 puts "if statement is working for second condition" serviceDetailsHash["direction"] = directionArray[1].inner_html end Hope this helps, Lyle