Ruby/Rails是否具有++等价物?

Gan*_*kar 6 ruby-on-rails operators

我想我只是习惯说:

x++
Run Code Online (Sandbox Code Playgroud)

在PHP和Java领域.但是当我在我的Rails代码中尝试这个时,它有一个合适的:

compile error
/users/gshankar/projects/naplan/app/views/answers/new.html.haml:19: syntax error, unexpected ';'
/users/gshankar/projects/naplan/app/views/answers/new.html.haml:23: syntax error, unexpected kENSURE, expecting kEND
...}\n", 0, false);_erbout;ensure;@haml_buffer = @haml_buffer.u...
                              ^
/users/gshankar/projects/naplan/app/views/answers/new.html.haml:26: syntax error, unexpected $end, expecting kEND
Run Code Online (Sandbox Code Playgroud)

我搜索了Ruby/Rails运算符,以获取对++的引用,但找不到任何东西.对于一种专注于写作较少的语言,我觉得有点奇怪的是没有相应的++.我错过了什么吗?

igu*_*222 5

x+=1 是您在 Ruby 中可以做的最好的事情。

有关详细说明,请参阅为什么 Ruby 不支持 i++ 或 i--?(递增/递减运算符)?