Hello to all,
I have a ruby script with a very long hash with more than 300 associations.
The script looks like below:
#!/usr/bin/env ruby
Array_A = []
myHash = {
"x1" => "2",
"x2" => "0",
"x3" => "1",
.
.
.
"X350" => "1"
}
myHash.keys.each do |z|
Array_A << "This is key " + z
end
puts myHash.values.join("|")
puts Array_A.join("|")
But since the hash is very large, for reading purposes I'd like to put the hash at the end of the script and the each.do loop and puts command first,
something like below.
Is there a way to do this?
Thanks in advance for any help.
Array_A = []
myHash.keys.each do |z|
Array_A << "This is key " + z
end
puts myHash.values.join("|")
puts Array_A.join("|")
myHash = {
"x1" => "2",
"x2" => "0",
"x3" => "1",
.
.
.
"X350" => "1"
}