Reputation: 1239
I am writing some code as a solution for a programming problem. I have just introduced a new function into my solution which is causing the following errors. Note that the errors are not there without this function.
search.rb:48: syntax error, unexpected keyword_end
search.rb:68: syntax error, unexpected $end, expecting keyword_end
I realize that this is caused by a mispaced end. I just can't find it. (I have marked the location of the first error with a comment. The second error is the last line of code and not shown here.)
def processing_function
qcount = pcount = $n
qstrength = 0
$query_hash.each do |qkey, qvalue|
print "Q",qkey,": "
$page_hash.each do |pkey, pvalue|
qvalue.each_index do |i|
pvalue.each_index do |j|
if qvalue[i]==pvalue[j]
qstrength = qstrength + qcount*pcount
end
pcount--
end #** This is line 48. First error occurs here. **#
qcount--
pcount=$n
end
if qstrength!=0
print "P",pkey," "
end
qstrength=0
end
print "\n"
end
end
Upvotes: 0
Views: 379
Reputation: 4847
Ruby doesn't have --
or ++
operator. Use, for example += 1
instead.
There is short article about differences for C/C++ and Ruby.
Upvotes: 4