You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This change will make composite literals easier to write for types containing structs, slices and maps. It doesn't seem to require any language changes and doesn't seem to break previously valid Go code.
The change can be argued with on the premise of "reducing readability", but consider the counter example:
t:=&T{
Items: createMap(), // no type in sight
}
However, this might allow to write shorter code because you'll avoid repeating types. The refactoring of struct member types might also become easier as you won't need to change types inside composite literals.
This doesn't seem to require any language/spec changes and doesn't seem to break previously valid Go code (please feel free to correct me if I'm wrong).
The text was updated successfully, but these errors were encountered:
Currently, we can omit types inside slice initialization and map initialization, for example:
This can be allowed in more contexts.
1. Allow to omit types in composite literal
Before:
After:
2. Allow to omit return types inside "return" statement.
Before:
After:
This change will make composite literals easier to write for types containing structs, slices and maps. It doesn't seem to require any language changes and doesn't seem to break previously valid Go code.
The change can be argued with on the premise of "reducing readability", but consider the counter example:
However, this might allow to write shorter code because you'll avoid repeating types. The refactoring of struct member types might also become easier as you won't need to change types inside composite literals.
This doesn't seem to require any language/spec changes and doesn't seem to break previously valid Go code (please feel free to correct me if I'm wrong).
The text was updated successfully, but these errors were encountered: