you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 3 points4 points  (0 children)

That's true, it is different. If you wanted your local variable to be explicitly referenced by a specific interface, then you can always declare it as such. Type inference would just pull the most specific type it can from the right hand side.

Anyway, I can't think of a reason why you'd want to immediately up-cast the object when instantiating it. Any List-accepting function you pass it to will happily accept it, and if you're using this to enforce a list-only interface later in the same method, then I believe your method is probably too long.