From: Shuaib Zahda Date: 2007-10-22T13:53:48+09:00 Subject: Class variables I have tried to deal with class variables but I received weird output the code is here and below it is the output class ClassVariable attr_accessor :total @@num1 = 0 @@num2 = 0 def getValues puts "enter a number" @@num1 = gets puts "enter a number" @@num2 = gets end def sum @@num1 + @@num2 end end obj = ClassVariable.new obj.getValues puts obj.sum -- output enter a number 4 enter a number 5 4 5 as u can see in the output it just repeats them and did not sum them up and returns the summation value. any idea? Regards Shuaib -- Posted via http://www.ruby-forum.com/.