The short assignment statement ":=" does not work outside functions

I was wondering WHY does := not work outside functions? Is it related to type inference not working outside functions during compile time?

Hoping the devs at GO could shed some light to this.

The parser is simpler if every top level declaration begins with a keyword. Hence the requirement for var.

3 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.