How to avoid applied lazily Lists.transform in guava?

后端 未结 3 1659
死守一世寂寞
死守一世寂寞 2021-01-11 15:11
Map map = Maps.newHashMap();
map.put(\"test\",\"123\");
map.put(\"fuyou001\",\"456\");
map.put(\"id\",1         


        
3条回答
  •  难免孤独
    2021-01-11 16:07

    Functions in general should not have side effects; that's your real problem.

    That said, if you insist on applying the transformation immediately, do a copy: Lists.newArrayList(Lists.transform(list, function)).

提交回复
热议问题