The precedence tables in many Ruby documentations out there list binary arithmetic operations as having higher precedence than their corresponding compound assignment operators. This leads me to believe that code like this shouldn't be valid Ruby code, yet it is.
1 + age *= 2
Run Code Online (Sandbox Code Playgroud)
If the precedence rules were correct, I'd expect that the above code would be parenthesized like this:
((1 + age) *= 2) #ERROR: Doesn't compile
Run Code Online (Sandbox Code Playgroud)
But it doesn't.
So what gives?
我正在尝试调试我用C++编写的程序.这是代码:
void a() { }
void b() { a(); }
int main() { b(); return 0; }
Run Code Online (Sandbox Code Playgroud)
我用它编译:g++ -g3 -O0 -o cards.exe cards.cpp.这是我的gdb会话的输出:
(gdb) b main
Breakpoint 1 at 0x401421: file cards.cpp, line 10.
(gdb) r
Starting program: C:\workspace\Cards\src/cards.exe
[New thread 1624.0xa28]
Breakpoint 1, main () at cards.cpp:10
10 int main()
(gdb) n
12 b();
(gdb) n
b () at cards.cpp:5 5
void b()
(gdb) n
7 a();
(gdb) quit
The program is running. Exit anyway? (y or …Run Code Online (Sandbox Code Playgroud)