Java Lambda in Intellij: Expected not null but the lambda body is not value-compatible -
trying filter collection using stream, , trying pass following lambda filter() set, gives arcane error in title:
unmatchedincomingfields.stream().filter(s-> s.matches(fieldmatchpattern))
meanwhile, creating predicate object works:
unmatchedincomingfields.stream().filter(new predicate<string>() { @override public boolean test(string s) { return s.matches(fieldmatchpattern); } });
according jls, lambda body "value-compatible" if every control path returns value. matches() gets called , returns boolean, don't understand problem is.
i've tried kinds of variations of same lambda- , without parentheses , argument types , using expression , block-with-return bodies.
the issue looks incorrect, or @ least misleading, error highlighting within intellij, confusing actual error was.
the filter occurs within lambda map() operation had not specified return yet, , reason, intellij highlights inner lambda filter, making 1 error.
Comments
Post a Comment