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
Go clearly defines what the "default" or "zero" value of a type is, whether it be 0, "", false, nil or whatever. With this in mind, consider the following code snippet:
I propose that we allow the _ character to represent the default, or "zero" value, of a given type when returning from a function. This would amend the original example to the following:
This change would reduce time spent checking return types and their default values (when I first started learning Go, returning time.Time{ } for an empty time really threw me). I feel this change would also be semantically meaningful with the current uses for the _ symbol.
The text was updated successfully, but these errors were encountered:
This indeed looks like a dup. Let's keep the discussion in that thread. If your proposal has any differences that you think add to the conversation, of course feel free to add them there. Thanks!
I spent so long looking for something similar to this but limited my results to "return types". I knew there would be a duplicate. Thanks for pointing me in the right direction.
Go clearly defines what the "default" or "zero" value of a type is, whether it be
0
,""
,false
,nil
or whatever. With this in mind, consider the following code snippet:I propose that we allow the
_
character to represent the default, or "zero" value, of a given type when returning from a function. This would amend the original example to the following:This change would reduce time spent checking return types and their default values (when I first started learning Go, returning
time.Time{ }
for an empty time really threw me). I feel this change would also be semantically meaningful with the current uses for the_
symbol.The text was updated successfully, but these errors were encountered: