Hi Stefano (aka stefanocheri / freenet.de [mailto:stefanocheri / freenet.de]): You wrote last Thursday, December 12, 2002 5:09 PM: > Hello, > > i don know how to build a loop for the following problem: > > class TestClass > def input(num1,num2,num3,num4,num5,num6) #<-- does that > make sense? Is it right? personal opinion, no, it does not make sense. You have to trust your instincts :-) > @num1=num1 > @num2=num2 > @num3=num3 > @num4=num4 > @num5=num5 > @num6=num6 > end > > attr_accessor :num1 > attr_accessor :num2 > attr_accessor :num3 > attr_accessor :num4 > attr_accessor :num5 > attr_accessor :num6 > end > > ob = TestClass::new > > 6.times do |i| > print "Enter number #(i+1): " > ob.num[i]=gets.to_f #<---this is my problem yes, one of your problems ;-) > end > > Maybe youe found some other mistakes or things i should do > better. I be very happy if you¥¨ld help me ¥¨cause i¥¨m very > new to ruby. Thank you very much. > C:\family\ruby>type a1.rb class TestClass attr_accessor :num1 attr_accessor :num2 attr_accessor :num3 attr_accessor :num4 attr_accessor :num5 attr_accessor :num6 end ob = TestClass.new 6.times do |i| print "Enter number #{i+1}: " eval("ob.num#{i+1}=gets.to_f") #<---this is your problem? end # you have to output your test inputs 6.times do |i| print "number #{i+1}: " eval("p ob.num#{i+1}") end C:\family\ruby>ruby a1.rb Enter number 1: 2 Enter number 2: 123 Enter number 3: 56 Enter number 4: 78 Enter number 5: 45 Enter number 6: 9999 number 1: 2.0 number 2: 123.0 number 3: 56.0 number 4: 78.0 number 5: 45.0 number 6: 9999.0 [personal opinion] If you have "eval" in your code, there is possibly something wrong with the way your program is structured... I think you are testing ruby syntax. Test syntax one-by-one first. Then connect each slowly... this is my style though... I am a nuby ;-) In programming, you always ask, why and why not. The two always go together ;-) Again, this is just my opinion... as a nuby... > Kind regards, > Stefano kind regards, -botp