This is like using an Object[], but with names and no second level of boxing…
> On Nov 16, 2017, at 4:10 AM, John Rose <[email protected]> wrote: > > On Nov 15, 2017, at 5:15 PM, Remi Forax <[email protected] > <mailto:[email protected]>> wrote: >> >> List<String> list = List.of("hello", "world!"); >> Map<Integer, String> map = list.stream() >> .map(s -> new Object() { int key = s.length(); String value = s; }) >> .collect(Collectors.toMap(t -> t.key, t -> t.value)); >> System.out.println(map); >> >> so i guess 'leaking' the type of an anonymous class is not an issue. > > That's cool; I didn't know Java had anonymous tuples!!!
