Last active
March 1, 2018 15:54
-
-
Save rayway30419/2c0fe56aeb38321795e7ab03c9f38b9a to your computer and use it in GitHub Desktop.
Hash#default_proc
This file contains 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
videos = Hash.new do |h,k| | |
h[k] = "https://www.youtube.com/watch?v=#{k.to_s}" | |
end | |
%w(vVyf_TqWVzI cZFPVAOrdXQ 5tQ4xHMR3iU).each { |id| videos[id] } | |
puts videos | |
# { | |
# "vVyf_TqWVzI"=>"https://www.youtube.com/watch?v=vVyf_TqWVzI", | |
# "cZFPVAOrdXQ"=>"https://www.youtube.com/watch?v=cZFPVAOrdXQ", | |
# "5tQ4xHMR3iU"=>"https://www.youtube.com/watch?v=5tQ4xHMR3iU" | |
# } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment