T
Tim Wolak
I've been looking for a way to change a hash key. In my code I'm trying
to change the key from a number to a string. Do I need to convert the
key to a string and put it new value in there or is my code wrong?
Thanks in advance,
Tim
def numbers
@skty = Hash.new(0)
@sktynl.each do |key, value|
if key <= "39"
key = "SKTY"
@skty[key] += value # !> instance variable @skty
not initialized
elsif key >="40"
key = "SKYNY"
@skty[key] += value
end
to change the key from a number to a string. Do I need to convert the
key to a string and put it new value in there or is my code wrong?
Thanks in advance,
Tim
def numbers
@skty = Hash.new(0)
@sktynl.each do |key, value|
if key <= "39"
key = "SKTY"
@skty[key] += value # !> instance variable @skty
not initialized
elsif key >="40"
key = "SKYNY"
@skty[key] += value
end