In part one I gave a bunch of reasons to reject the proposed feature where the compiler infers additional type information about a local variable when inside the consequence of a conditional statement:
if (animal is Dog)
{
animal.Bark();
// instead of ((Dog)animal).Bark();
}
But the problem still remains that this is a fairly common pattern, and that it seems weird that the compiler cannot make the necessary inference.
A number of readers anticipated my denouement and made some of the same proposals I was going to make in this part. Let’s go through a few of them; see the comments to the previous article for a few more.
Continue reading →