Code blocks are just lambdas though? It's pretty much mainstream these days, even Java and C++ have them.
// java equivalent
int numberOfAuthors = arr.stream().map(BlogPost::getAuthor).distinct().collect(Collectors.toList()).size();
I happen to think for loops are usually a better choice in languages like Java, but the option is there.EDIT: actually there's a better way, no need to create a list just to count its elements:
int numberOfAuthors = arr.stream().map(BlogPost::getAuthor).distinct().collect(Collectors.counting());