Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 Java 中,类似的东西i++会增加i1。
i++
i
在 Ruby 中我该怎么做?肯定有比i = i + 1?
i = i + 1
从文档中,
Ruby 没有前置/后置递增/递减运算符。例如,x++ 或 x-- 将无法解析
所以,你可以做
i += 1
这相当于i = i + 1