3 ms·
One of Go's other design decisions is signalling failures by returning errors. Multiple return values makes it possible to do that and also return a real value.
by twic 10y ago
One of Go's other design decisions is signalling failures by returning errors. Multiple return values makes it possible to do that and also return a real value.
If you didn't have multiple return values, you would have to do something ugly: C-style pseudo-return via a passed-in pointer, or returning an error or a value as an interface{} and requiring the caller to type-switch on it. Or add a special case to the language to somehow allow an error return alongside a normal return. Multiple return makes this straightforward and uniform.
- Keyframe 10y agoAlright, that actually makes sense. Thanks.