Sorry - I was careless and didn't test the code... Martin DeMello <martindemello / yahoo.com> wrote: > class TestClass > > attr_accessor :num > > def input(*args) # input a variable number of arguments, put them in an > # array called args that should be def initialize(*args) when you call new on your class, that calls the initialize method you provide. > > if args.length != 6 > raise "six arguments expected" > end > > # now we can capture the arguments in an instance variable > @num = args # note that @num is now a six-element array > > end > > end #class TestClass > > ob = TestClass.new Also, you seem to be doing something different here - if you're setting the values for num in the loop, you don't need to pass anything to initialize. So your code should look like class TestCase attr_accessor :num def initialize @num = [] end end ob = TestClass.new print "How many numbers to input? " n = gets.chomp.to_i 0.upto(n-1) do |i| print "Please enter number #{i+1}: " ob.num[i] = gets.chomp.to_f end You could make the whole thing a method of TestCase: class TestCase attr_accessor :num def initialize @num = [] end def input_nums print "How many numbers to input? " n = gets.chomp.to_i 0.upto(n-1) do |i| print "Please enter number #{i+1}: " num[i] = gets.chomp.to_f end end end ob = TestClass.new ob.input_nums martin