Created
August 29, 2019 20:23
-
-
Save itskaia/d48a8d300ac6ec3fe6e68371a2b4c57c to your computer and use it in GitHub Desktop.
Thing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The goal is to build a loop that pushes a hash into an array. Each time a new hash is pushed into the array, the number at the end of the hash's assigned name increases by +1 (eg: question_1, then question_2, etc...) | |
# Basically I've been trying to figure out how to turn a string with an integer interpolation for each successive +1 into a new hash name. | |
question_superset_test = [] | |
question_1 = {} | |
puts "Enter question:" | |
question_entry = $stdin.gets.chomp.to_s | |
question_1.merge!(prompt: "#{question_entry}") | |
puts question_1 | |
puts "Enter answer A)" | |
answer_a_entry = $stdin.gets.chomp.to_s | |
question_1.merge!(answer_A: "#{answer_a_entry}") | |
puts question_1 | |
question_superset_test.push(question_1) | |
puts "Here's the array:" | |
puts question_superset_test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment