ruby for in 循环中改变i的值无效

ruby for in 循环中改变i的值无效

for j in 1..5
  puts "#{j}hehe"
  j = j + 2
  #break
end

在循环中,使用j = j + 2进行修改是无效的,还要循环5次;

在RubyMine中能够看出两个j的颜色都是不一样的;

原文地址:https://www.cnblogs.com/stono/p/6666566.html