4 ms·
I don't understand these complaints. Here is a tiny interface that will do what you need: @FunctionalInterface public interface IPasswordChecker {
by throwaway2037 1y ago
I don't understand these complaints.
Here is a tiny interface that will do what you need:
@FunctionalInterface
public interface IPasswordChecker
{
bool isValid(String password);
}
Now you can trivially declare a lambda that implements the interface.
Example:
const IPasswordChecker passwordChecker = (String password) -> password.length() >= 16;
- abrenuntio 1y agoI'm personally rather fond of Java, but even this (or the shorter `Predicate`) still can't compete with the straightforward simplicity of a type along the lines of `string -> bool`.
- throwaway2037 1y agoI bet you are the kind of person who uses "auto" a lot in whatever programming language that you use. For me, context matters because, in the words of Joel Spolsky, (1) you read code much more than you write code, and (2) it is harder to read code than write code. As a result, I always choose the more verbose form when writing code that other people will read.