代码拉取完成,页面将自动刷新
同步操作将从 D语言中文社区/Programming-in-D 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
Ddoc
$(DERS_BOLUMU Assignment and Order of Evaluation)
$(P
The first two difficulties that most students face when learning to program involve the assignment operation and the order of evaluation.
)
$(H5 The assignment operation)
$(P
You will see lines similar to the following in almost every program in almost every programming language:
)
---
a = 10;
---
$(P
The meaning of that line is "make $(C a)'s value become 10". Similarly, the following line means "make $(C b)'s value become 20":
)
---
b = 20;
---
$(P
Based on that information, what can be said about the following line?
)
---
a = b;
---
$(P
Unfortunately, that line is not about the equality concept of mathematics that we all know. The expression above $(B does not) mean "a is equal to b"! When we apply the same logic from the earlier two lines, the expression above must mean "make $(C a)'s value become the same as $(C b)'s value".
)
$(P
The well-known $(C =) symbol of mathematics has a completely different meaning in programming: make the left side's value the same as the right side's value.
)
$(H5 Order of evaluation)
$(P
In general, the operations of a program are applied step by step in the order that they appear in the program. (There are exceptions to this rule, which we will see in later chapters.) We may see the previous three expressions in a program in the following order:
)
---
a = 10;
b = 20;
a = b;
---
$(P
The meaning of those three lines altogether is this: "make $(C a)'s value become 10, $(I then) make $(C b)'s value become 20, $(I then) make $(C a)'s value become the same as $(C b)'s value". Accordingly, after those three operations are performed, the value of both $(C a) and $(C b) would be 20.
)
$(PROBLEM_TEK
$(P
Observe that the following three operations swap the values of $(C a) and $(C b). If at the beginning their values are 1 and 2 respectively, after the operations the values become 2 and 1:
)
---
c = a;
a = b;
b = c;
---
)
$(Ergin)
Macros:
SUBTITLE=Assignment and Order of Evaluation
DESCRIPTION=The very first two hurdles that a student faces when learning to program
KEYWORDS=d programming language tutorial book
MINI_SOZLUK=
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。