Skip to content

Instantly share code, notes, and snippets.

@paul
Created October 16, 2008 20:56
Show Gist options
  • Save paul/17260 to your computer and use it in GitHub Desktop.
Save paul/17260 to your computer and use it in GitHub Desktop.
# I have a set of questions, each of which have a default (default_answers)
# I also have a set of answers for questions, but not every question (answers)
# I want an array of every answer, priority to the actual answers, but filling
# in the default answer when no actual answer exists.
def all_answers
all_answers = {}
default_answers.each do |answer|
all_answers[answer.question_name] == answer
end
answers.each do |answer|
all_answers[answer.question_name] == answer
end
all_answers.values
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment