(undefined `+ @ 'method for []: array)

I get a very strange error message when I try to iterate over an array of objects. Mistake

NoMethodError (undefined method `+@' for []:Array):

Here is the code for this loop.

#go through items and see if there are any corresponding offers 
    #All matches are stored in a hash
    items.each do |itemsi|
        bestoffer = -1
        matchescounter++ #matchescounter only get incredmented when all the offers have been taken care of
        offers.each do |offs|
        if itemsi.togive.to_str == offs.totake.to_str
            if offs.togive.to_int > bestoffer
                bestoffer = offs.togive.to_int
                matches[matchescounter].store(itemi, offer)         
            end#if
        end#if
        end#offers loop
    end#items loop

I don't have + @ anywhere in my code. Weird

+3
source share
1 answer

There is no ++ operator in Ruby.

And the error message is actually pretty clear: it says that the method named '+ @' does not exist for your instance of type Array. '+ @' is the actual name of the unary plus instance method, which is defined for the Numeric type, but not for the array.

+11
source

Source: https://habr.com/ru/post/1717794/


All Articles