|
|
|
|
|
by josephlord
4183 days ago
|
|
enums and structs are value types (and Result is an enum) so I think that you could just return self for the error case (gaining cleanliness and a little efficiency). Objects (of classes) are reference types so if Result was a class there would be a difference between returning self and returning a new Result. |
|
Yeah, this is correct. This would be wrong:
As for efficiency: like you mention, enum are value types. For this reason, they're passed by copy! So even returning self would return a copy of self, not the same instance :)