Why Func instead of Predicate?

This is just a curiosity question I was wondering if anyone had a good answer to: In the .NET Framework Class Library we have for example these two methods: public static IQueryable<TSource> Where<TSource>( this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate ) public static IEnumerable<TSource> Where<TSource>( this IEnumerable<TSource> source, Func<TSource, bool> predicate ) Why do they use … Read more

How to negate a method reference predicate

In Java 8, you can use a method reference to filter a stream, for example: Stream<String> s = …; long emptyStrings = s.filter(String::isEmpty).count(); Is there a way to create a method reference that is the negation of an existing one, i.e. something like: long nonEmptyStrings = s.filter(not(String::isEmpty)).count(); I could create the not method like below … Read more