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

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -