V2EX  ›  英汉词典

Augmented Assignment

定义 Definition

Augmented assignment(增量赋值/复合赋值)是编程里的写法:把“运算 + 赋值”合并成一个操作符,例如 x += 1 等价于 x = x + 1。常见形式包括 +=-=*=/=%=<<=&= 等。(在不同语言中细节可能略有差异。)

发音 Pronunciation (IPA)

/ɔːɡˈmɛntɪd əˈsaɪnmənt/

例句 Examples

I used augmented assignment to add 1 to the counter.
我用增量赋值把计数器加了 1。

In Python, augmented assignment like list += items may modify the original list in place, which can affect other references to it.
在 Python 中,像 list += items 这样的增量赋值可能会原地修改原列表,从而影响对它的其他引用。

词源 Etymology

augmented 源自拉丁语 augmentare(“增加、扩充”);assignment 来自 assign(“分配、指派”),在编程语境中指“给变量赋值”。合起来就是“带有额外运算的赋值方式”。

相关词 Related Words

文学与作品 Literary Works

  • Python Language Reference(Python 官方语言参考文档)中有 “Augmented assignment statements” 相关章节
  • PEP 203 — Augmented Assignments(Python 增量赋值提案)
  • Learning Python(Mark Lutz)涉及 += 等增量赋值的行为与注意事项
  • JavaScript: The Definitive Guide(David Flanagan)讲解 += 等复合赋值运算符
  • The C Programming Language(Kernighan & Ritchie)涵盖 +=*= 等复合赋值运算符的用法
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   1734 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 08:05 · PVG 16:05 · LAX 00:05 · JFK 03:05
♥ Do have faith in what you're doing.