From: Dave Thomas Date: 2001-08-24T11:40:56+09:00 Subject: [ruby-talk:20237] Re: Example 1: Was Ruby Article Joshua Drake writes: > addrFields = ["First Name", "Last Name", "Phone Number"] > > x = 0 > loop do > print "\n\t#{addrFields[x]}: " > getLine = gets > break if getLine == "END\n" > addrData[x] = getLine.chop! > x += 1 > if x == addrFields.length > aBook.puts addrData.join("\t") > addrData.clear > x = 0 > end > end > puts "\n\nTo start the program again please type addr.rb\n\tGoodBye!\n" > end I guess my main comments would be: 1. It crashes if the user enters an end of file 2. It should probably be chop, not chop! 3. The use of an indexing variable doesn't seem very Ruby-ish, but that's probably just a personal thing on my part. My inclination would be for something like: addrFields = ["First Name", "Last Name", "Phone Number"] addrData = [] loop do addrFields.each do |prompt| print "\n\t#{prompt}: " line = gets break if !line || line == "END\n" addrData << getLine.chop end break if addData.size < addFields.size aBook.puts addrData.join("\t") addrData.clear end I have to say that I'm impressed that you are putting your code up for scrutiny like this. Thank you. Dave Dave