4 ms·
> Do you know what := does in Go? What "common conventions" provide the same concise expressiveness? I know what := means because I have a Pascal background, m
by halayli 15y ago
> Do you know what := does in Go? What "common conventions" provide the same concise expressiveness?
I know what := means because I have a Pascal background, most programmers are used to = as being the assignment operator. But the mere fact that you asked me what ":=" means proves my point. It's not common and you don't expect everyone to know it.
Why range doesn't require parenthesis? It takes parameters just like make does.
- mpolun 15y ago:= in go means "declare this variable and infer it's type" You can always use i E = range e or similar, also range is not a function, it's part of go's syntax and always takes one argument. You don't need parens for the unary - operator. Go does have different syntax from most C derived languages, but the differences are there for a reason. You need to learn any language to understand it.
- enneff 15y ago"I know what := means because I have a Pascal background" But it's not the same: in Pascal := means assignment, whereas in Go it means variable declaration. Go uses = for assignment, as is the popular convention. You must learn new things when you learn a new programming language. People should stop being surprised and/or upset by this. Besides, Go's syntax is not all that shocking or unusual, especially compared to Scala, Erlang, or Haskell. I regularly switch between Go, JavaScript, C, and Python and don't have any trouble adjusting. "Why range doesn't require parenthesis? It takes parameters just like make does." Range is a keyword, while make is a function. Range is used with a single value (the map, slice, or channel being ranged over), while make may take up to three arguments. Please - it is really silly to critique the syntax of a language if you don't know the language.