Stefano Crocco wrote:
> On Wednesday 06 October 2010, Paul Roche wrote:
>> |Hi. When I use class variables with operators I get the following error
>> |message........
>> |
>> | undefined method `>' for nil:NilClass
>> |
>> |
>> |here's a piece of code that gives this error.....
>> |
>> |if @@target1 <  @@target2
>> |   @@status = true
> 
> It means that @@target1 is nil. Try
> 
>   p @@target1
> 
> just before the if and see what it shows.
> 
> Stefano

The problem is I intialise the attributes first.......

def initialize(tar1, tar2)
@@target1 = tar1
@@target2 = tar2
end


Then I use this method....

def self.on_target?(mltn)
mltn.each do |trg|
if trg.target1 > trg.target2
then p "on target"
else
off_target
end
end
end

and call this method in the method above...

def off_target
@@target1 = @@target1 - @@target2
end

So I want to make off_target accessable which is why I use @@

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