| ▲ | fatih-erikli-cg 4 days ago |
| := for assinging a variable sounds and looks weird to me |
|
| ▲ | steve_adams_86 4 days ago | parent | next [-] |
| It's the walrus operator. Pascal and Python use it as well. You get used to it pretty quickly. Pascal: https://www.freepascal.org/docs-html/ref/refse104.html#x224-...
Python: https://docs.python.org/3/whatsnew/3.8.html#assignment-expre... |
| |
| ▲ | fatih-erikli-cg 4 days ago | parent [-] | | It was something introduced like a 1 april joke. Clean implementation of any programming language won't have that. | | |
| ▲ | hnlmorg 4 days ago | parent | next [-] | | I actually think it’s more readable because it makes the distinction between assignment and equivalence very clear. bugs originating from the similarity of == vs = has probably cost the industry millions over the last 3 decades. | |
| ▲ | kortex 4 days ago | parent | prev [-] | | That ship has long sailed. ALGOL 1958 used := and Pascal popularized it. https://en.m.wikipedia.org/wiki/Assignment_(computer_science... | | |
| ▲ | fatih-erikli-cg 4 days ago | parent [-] | | I think they scan the code by two characters because one is not enough for <= and => so what is why assignment is := or =:. Probably + is ++ too. |
|
|
|
|
| ▲ | linhns 4 days ago | parent | prev | next [-] |
| I think it's good. 2 characters for declaration + assign. |
|
| ▲ | indulona 4 days ago | parent | prev [-] |
| it's just a shorthand for var foo int = 5 vs foo := 5 where the type is derived from the assigned value. |
| |