Is this correct usage of lambdas in Java 8? -
final list<string> userids = request.getuserids(); final list<string> keys = userids.stream().map(p -> { return removeprefix(p); }).collect(collectors.tolist());
basically, every key in list of userids
contains prefix "_user" want remove every key. so, invoking removeprefix
function on each item of list , storing result in list called "keys"
yes it's fine although make little shorter , more readable method reference , static import:
final list<string> keys = userids.stream() .map(this::removeprefix) .collect(tolist());
Comments
Post a Comment