is there java8 equivalent way of writing following?
list<foo> results = new arraylist<>(); (rowresult row : rows) { results.add(rowtofoofunction(classroomlookup.get(row.getid()), studentlookup.get(row.getid())).apply(row)); }
where rowtofoofunction function<rowresult, foo> rowtofoo (classroom c, student s)...
so end like:
rows.stream.map(rowtofoofunction...).collect(collectors.tolist());
the problem is, in map step, need lookup student/classroom id of row iterating over.
you found solution already, close:
list<foo> results = rows.stream().map(row -> rowtofoofunction(classroomlookup.get(row.getid()), studentlookup.get(row.getid())).apply(row)) ).collect(collectors.tolist());
Comments
Post a Comment