Well I have a question object that as you can see it receives parameters true / false, what I would like is that in the variable question_type given the value of questions[:q1] it is assigned one of the functions question_type_true or question_type_false to be able to execute it within the each.
questions = {
q1: true,
q3: true,
q4: true,
q5: true,
q6: true,
q7: true,
q8: true
}
question_type = questions[:q1] == true ? question_type_true : question_type_false
questions.each do |key, value|
question_type(value)
end
def question_type_true(question)
p "true function #{question}"
end
def question_type_false(question)
p "false function #{question}"
end
example:
questions = { q1: false, q3: true, q4: true}
output:
p "true function false"
p "true function true"
p "true function true
questions[:q1] == falsewhich would result in the usage of thequestion_type_falsemethod not thequestion_type_truemethod as your output suggests