Created
June 15, 2017 22:23
-
-
Save asterion/a7ddec3f9741d6005e255887003ef273 to your computer and use it in GitHub Desktop.
rellenar un hash en ruby
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
meses = { | |
"ENERO" => [0], | |
"FEBRERO" => [0], | |
"MARZO" => [0], | |
"ABRIL" => [0], | |
"MAYO" => [0], | |
"JUNIO" => [0], | |
"JULIO" => [0], | |
"AGOSTO" => [0], | |
"SEPTIEMBRE" => [0], | |
"OCTUBRE" => [0], | |
"NOVIEMBRE" => [0], | |
"DICIEMBRE" => [0] | |
} | |
foo = { | |
"UNIDAD" => ["UNIDAD"], | |
"ENERO" => ["23", "0", "0", "0", "0", "0", "0", "0", "0", "0"], | |
"FEBRERO" => ["23", "0", "0", "0", "0", "0", "0", "0", "0", "0"], | |
"MARZO" => ["34", "0", "0", "0", "0", "0", "0", "0", "0", "0"] | |
} | |
meses.each do |key, value| | |
unless foo.has_key?(key) | |
foo[key] = value | |
end | |
end | |
puts foo["DICIEMBRE"] | |
puts foo["ENERO"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment