Lew<lewbloch@gmail.com> wrote:
Andreas Leitgeb wrote:
I'd favor a different change: let final variables optionally
have their type inferred:
final myList = new ArrayList<String>();
Afterall, it is just a handle for some previously obtained value.
That idea is more complex than it appears. Should the inferred type be
'List<String>', 'AbstractList<String>' or 'ArrayList<String>'?
I suspect you would say the last,
You suspected right, which is no surprise, as it is the only reasonable
choice in that particular context.
but really, is it so very, very bad to type
final List<String> myList = new ArrayList<>();
I find the direction of the inferral somewhat unlucky.
I'd rather infer the type from right(expression) to left(variable),
than the other way round. I guess that was discussed thoroughly
before it was introduced, so I might just miss knowing those perfect
arguments against my preferrence.
I prefer the Java way.
and then move further down the code.
will just make it more difficult (in that case).