我在多个代码示例中看到过 :=
使用,但从未附带过解释。如果不知道它的正确名称,就不可能通过谷歌搜索它的用途。
它有什么作用?
最佳答案
http://en.wikipedia.org/wiki/Equals_sign#In_computer_programming
In computer programming languages, the equals sign typically denotes either a boolean operator to test equality of values (e.g. as in Pascal or Eiffel), which is consistent with the symbol's usage in mathematics, or an assignment operator (e.g. as in C-like languages). Languages making the former choice often use a colon-equals (:=) or ≔ to denote their assignment operator. Languages making the latter choice often use a double equals sign (==) to denote their boolean equality operator.
注意:我通过搜索冒号等于运算符
找到了这个
关于operators - ":="有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5344694/