#input_from_the_net = ""
my_array = [ ["Header name" , input_from_the_net] ]
input_from_the_net = "a value scraped from the net"
puts "#{my_array[0][0]} is #{my_array[0][1]}"
EDIT:
I use the variable input_from_the_net
later on in the loop and assign its value into a hash. That hash is then stored inside another hash. If I use input_from_the_net.replace("a value scraped from the net")
it replaces the value inside all hashes. That is not desired. I want all hashes to keep the correct values.
EDIT2: more detailed sample code
`require 'pp'
input_from_the_net = ""
def parse_the_website()
(0..5).each { |index|
input_from_the_net = index+23
@my_hash[index] = {@my_array[0][0] => input_from_the_net}
}
end
@my_array = [ ["Header name" , input_from_the_net] ]
#my_array is used on different places of the code
@my_hash = {}
parse_the_website
pp @my_hash
Q1: can I make this work and not change the order of lines?
Q2: if I uncomment #input_from_the_net = ""
the value of the variable input_from_the_net at the time of printing is "" not the "a value scraped from the net". How come?