From: Manish Kutaula Date: 2008-06-15T03:43:43+09:00 Subject: what is the error in this program class Customer @@no_of_customers=0 def initialize(id, name, addr) @id=id @name=name @addr=addr end def display_details() puts "Customer ID #@id" puts "Customer Name #@name" puts "Customer Address #@addr" @@no_of_customers+=1 end def total_customers puts "total no. of customers are #@@no_of_customers" end end while($_!="n") index=0; print "Enter user id " id=gets chomp print "Enter user name " name=gets chomp print "Enter user address " addr=gets chomp cust=Array.new cust[index]=Customer.new(id,name,addr) index+=1 print "do you want to enter more data y/n " gets chomp end 0.upto(index-1) do |c| puts cust[c].display_details() end Whenever i run this program and provide the input the display_details function show the details of only the last customer. -- Posted via http://www.ruby-forum.com/.