V
vimal
Hi,
I am a Ruby Newbie.
I wrote a function for stripping all the values(a recursive one if
it is a nested hash) but i almost end up in an
error suggesting "Error => in `strip_hash_values': stack level too
deep (SystemStackError)".
Can someone help me with this.
-------------------------------------------
Here's the code:
-------------------------------------------
def strip_hash_values(hash)
hash.each do |k, v|
if v.class == String
hash[k] == v.strip!
elsif v.class == Array
v.each do |vv|
vv.strip!
end
elsif v.class == Hash
strip_hash_values(hash)
end
end
end
Thanx,
Vimal Das
I am a Ruby Newbie.
I wrote a function for stripping all the values(a recursive one if
it is a nested hash) but i almost end up in an
error suggesting "Error => in `strip_hash_values': stack level too
deep (SystemStackError)".
Can someone help me with this.
-------------------------------------------
Here's the code:
-------------------------------------------
def strip_hash_values(hash)
hash.each do |k, v|
if v.class == String
hash[k] == v.strip!
elsif v.class == Array
v.each do |vv|
vv.strip!
end
elsif v.class == Hash
strip_hash_values(hash)
end
end
end
Thanx,
Vimal Das