var vs := in Go

In Go, top-level variable assignments must be prefixed with the var keyword. Omitting the var keyword is only allowed within blocks. package main var toplevel = “Hello world” // var keyword is required func F() { withinBlock := “Hello world” // var keyword is not required }

The forgotten assignment operator “=” and the commonplace “:=”

In PL/PgSQL parser, assignment operator is defined as assign_operator : ‘=’ | COLON_EQUALS ; This is a legacy feature, present in source code since 1998, when it was introduced – as we can see in the PostgreSQL Git repo. Starting from version 9.4 it is oficially documented. This idiosyncrasy – of having two operators for …

Read more

What does “:=” do?

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 ≔ …

Read more