In all languages that support an operator := it means assignment. In languages that support an operator := , the = operator usually means an equality comparison. In languages where = means assignment, == is typically used for equality comparison.
In ALGOL and Pascal, the assignment operator is a colon and an equals sign ( ":=" ) while the equality operator is a single equals ( "=" ).
In math, the colon-equals is meant for definitions, and is thus inherently global in nature; if you write "j := 0", you are making the statement that henceforth, "for all time", the symbol "j" will be synonymous with the symbol "0". (Cf "f'(x) := lim_{h -> 0}... [etc]".)
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.
Note: I found this by searching for colon equals operator
It's the assignment operator in Pascal and is often used in proofs and pseudo-code. It's the same thing as =
in C-dialect languages.
Historically, computer science papers used =
for equality comparisons and ←
for assignments. Pascal used :=
to stand in for the hard-to-type left arrow. C went a different direction and instead decided on the =
and ==
operators.
In the statically typed language Go :=
is initialization and assignment in one step. It is done to allow for interpreted-like creation of variables in a compiled language.
// Creates and assigns
answer := 42
// Creates and assigns
var answer = 42
Another interpretation from outside the world of programming languages comes from Wolfram Mathworld, et al:
If A and B are equal by definition (i.e., A is defined as B), then this is written symbolically as A=B, A:=B, or sometimes A≜B.
■ http://mathworld.wolfram.com/Defined.html
■ https://math.stackexchange.com/questions/182101/appropriate-notation-equiv-versus
Some language uses :=
to act as the assignment operator.
In a lot of CS books, it's used as the assignment operator, to differentiate from the equality operator =
. In a lot of high level languages, though, assignment is =
and equality is ==
.
A number of programming languages, most notably Pascal and Ada, use a colon immediately followed by an equals sign (
:=
) as the assignment operator, to distinguish it from a single equals which is an equality test (C instead used a single equals as assignment, and a double equals as the equality test).
Reference: Colon (punctuation).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With