24
Why is Go syntax so messy
(lemmy.ca)
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Follow the wormhole through a path of communities !webdev@programming.dev
The
:=
operator is called walrus operator and is inspired by Python I think. It's declaring a variable and assigning it in one go.map[string] int
is defining a map (associative array or also known as dictionary in Python), with string as key type and int as value type. And the following{}
is the body of the associative array, meaning empty content.I only played a bit with Go and did basic tutorials. I might go back to it at some point, but Zig is much more appealing to me. Go is too simple in the language to me, but on the other side, this is exactly whats appealing.
@thingsiplay @urska
':=' goes back to Pascal and maybe further. It also appears in PL/SQL. When I was learning to code my teacher told me to pronounce it as "becomes" since "equals" was for comparison.
Took me a while to get used to the C style '=='.