イベントに登録したメンバーの配列を作成しようとしていますが、複数のハッシュの配列を作成するのではなく、コードはハッシュに登録される最後のメンバーのみを格納します。理由が分からないようです。
total = 0
def registration
members = []
event = {}
puts "First Name: "; members << gets.chomp
puts "Last Name: "; members << gets.chomp
puts "Date of Birth: "; members << gets.chomp
puts "Number of Events(1-4): "; members << gets.chomp.to_i
total = '%.2f' % [(members[3] * 35.00)]
puts "TOTAL DUE: $#{total}"
event = {
:first_name => members[0],
:last_name => members[1],
:dob => members[2],
:events => members[3],
:paid => total
}
puts "Would you like to register another student?"
answer = gets.chomp.downcase
if answer == "yes"
registration
elsif answer == "no"
puts "Thank you for registering. We look forward to seeing you at the event."
p event
else
puts "Please enter 'yes' or 'no'."
end
end
registration