Skip to content

Instantly share code, notes, and snippets.

View artistwhocodes's full-sized avatar
:octocat:
studying code~

P.A artistwhocodes

:octocat:
studying code~
View GitHub Profile
question = ["Name", "Age", "Location", "Color"]
answer = ["Pam", "?", "Hogwarts", "green"]
infor_section = question.zip(answer).to_h
# => {"Name"=>"Pam", "Age"=>"?", "Location"=>"Hogwarts", "Color"=>"green"}
@artistwhocodes
artistwhocodes / zipper1.rb
Last active June 20, 2019 02:09
zip method merges array
question = ["Name", "Age", "Location", "Color"]
answer = ["Pam", "?", "Hogwarts", "green"]
infor_section = question.zip(answer)
# => => [["Name", "Pam"], ["Age", "?"], ["Location", "Hogwarts"], ["Color", "green"]]
question = ["Name", "Age", "Location", "Color"]
answer = ["Pam", "?", "Hogwarts", "green"]
infor_section = question.zip(answer).to_h
infor_section.each do |k , v|
puts "#{k}:"
puts "#{v}"
puts "\n"