i get strange error test.rb.rb:14: syntax error, unexpected ‘}’
makes no sense as the only time i use } is to close the each block. pl
help
require ‘fastercsv’
#put everything in an array
array = FasterCSV.read(“c:\temp\two.txt”)
seconds=0
lastminute=0
array.each{|row|
minute=row[1].split(":")[1].to_i
puts minute
puts lastminute
if(minute =lastminute) then
puts “same as last minute”
seconds=seconds+1
end if
}
On 6/10/2011 9:25 PM, Junkone wrote:
minute=row[1].split(":")[1].to_i
puts minute
puts lastminute
if(minute =lastminute) then
puts “same as last minute”
seconds=seconds+1
end if
}
You have an extra if' after the last
end’.
Su
You have a number of small syntax/logical errors here, I think. First,
the “then” in this line should be removed:
if(minute =lastminute) then
as should the “if” at the very end:
end if
Also, you probably meant “minute == lastminute”, not “=”, which will
assign lastminute to minute (that’s probably not what you want).
It should just be:
if minute == last_minute
# ...
end
~ jf
John F.
Principal Consultant, BitsBuilder
LI: http://www.linkedin.com/in/johnxf
SO: User John Feminella - Stack Overflow
On Sat, Jun 11, 2011 at 10:35:43AM +0900, John F. wrote:
Also, you probably meant “minute == lastminute”, not “=”, which will
assign lastminute to minute (that’s probably not what you want).
Also also . . . the code is horribly formatted, and it took me about
four
times as long as it should have to notice the errors in the code as a
result (which might be why my response is so much later than the other
two I see here).