小编No *_*ove的帖子

Why is a statement like 1 + n *= 3 allowed in Ruby?

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?

ruby

22
推荐指数
3
解决办法
1835
查看次数

GDB跨步功能(下一个)似乎不起作用

我正在尝试调试我用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)

c++ gdb

7
推荐指数
2
解决办法
2万
查看次数

标签 统计

c++ ×1

gdb ×1

ruby ×1