The two things appear alike but are very different. With local
variable type-inference, a la what you may know from C#, the type
flows from the concrete instance and is inferred continuously up the
expression tree. The diamond operator is much more limited and sort of
flows in reverse, and is really just a compiler hack to reduce the
amount of text when dealing with generic types.

I would also much prefer local variable type inference, since it
solves the same problem plus so much more. But it has been deemed too
complex a long time ago (few people dares touching the Java type
system it seems) so I doubt we'll ever see it.

On Sep 22, 5:21 pm, Serge Boulay <[email protected]> wrote:
> Is there some particular reason Oracle choose the diamond operator over
> something like “var” ?
>
> For example, I find this
>
> List<Employee> emps = new ArrayList<>();
>
> far less intuitive than say
>
> var emps = new ArrayList<Employee>();
>
> The second example has the added benefit that it would work with all types.

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to