From: Chris Pelow Date: 2009-11-25T03:00:42+09:00 Subject: Help with each_with_index method Hi there, I'm looking for help with my work here.I'm just learning Ruby. Basically I have 5 names entered into an array. They have a firstname and surname. A middlename is then optional. What I want to do is to print out the names like this.. John Seymour Smith Peter Jones Mary Walsh So it yields the middlename and prints it out if it has one. Some of my code is as follows... [code] people << Person.new("John", "Paul", "Smith" ) people << Person.new("Mary","Barry", "Jones" ) people << Person.new("Chris","Townsend", "Barry" ) people << Person.new("Peter","", "Murphy" ) people << Person.new("Scott","", "Evans" ) people_sorted = people.sort people_sorted.each do |person| people_sorted.each_with_index do|person, index| puts "Hi there #@index #@person!" end [/code] Attachments: http://www.ruby-forum.com/attachment/4289/Person2.rb -- Posted via http://www.ruby-forum.com/.