I'm all for intelligent compilers. On the other hand, as mentioned
1) it doesn't work with type-inference because there's unsolvable ambiguity
2) it doesn't work in a "purely" side-effecting scenario where the result is forgotten (of course here the Command Query Separation principle will dictate that you do not do that anyway)
3) it doesn't work in a scenario involving inheritance where both return types inherit from the same base type and the variable is of that base type
Please, do not speak evil about type-inference - it is hugely more important than this non-feature which will only save you keystrokes in a very limited set of scenarios that could be solved by choosing a different name; type-inference is pervasively important, this feature not so. So where could this be used?
1) when assigning to an explicitly typed variable, field or property where there is no inheritance ambiguity
2) when the return value is used as part of a function call and there is no inheritance ambiguity
Still, it's hugely less important than type-inference which saves keystrokes everywhere without sacrificing type safety (intent is expressed on the right hand side of the assignment symbol).
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.