4 ms·
I'm thinking more about your suggestion but off the top of my head I don't know why one would want a break reason. If one comes up anytime soon I'll 100% rememb
by levodelellis 4y ago
I'm thinking more about your suggestion but off the top of my head I don't know why one would want a break reason. If one comes up anytime soon I'll 100% remember this post
> I agree but declaring a name for what you return is nice because it explains the purpose of the returned values. They could go outside the ()s.
So you're not suggesting an 'out' keyword your saying names on return values? I like the idea but in practice I'm not sure if any IDE would show you the names? I think many do show comments if you place them the line before so that could be an alternative solution
One reason I don't like out params is because it conflicts with the design of the language. The language prefers you to assign variables and people will want to modify their variables (or arrays and struct members) with the out param and having something be declare OR assign causes problems because its too easy to make a typo and not find it for many many minutes. Writing the type then using out goes against the flow of the language which is why I prefer returning multiple values.
But I don't know all the use cases and everyones preference so there very well be a good reason you'd want an out parameter