How to use ruby code to realize “i = i + 1" operation

As it is Ruby, there are a few ways, however I don't think #i works as you expect. the # character is a single line comment until EOL character.

What the compiler is seeing is

  value = pmmeasValue["r"][
  hash[key] = value
  i =
end

Just use i e.g. value = pmmeasValue["r"][i]["content"].to_i

To increment a variable you can use any of:

i = i + 1
i += 1
i = i.succ
1 Like