wordCount function

int wordCount(
  1. String s
)

Count number of words separated by whitespace.

Implementation

int wordCount(String s) {
  return s.isEmpty ? 0 : words(s).length;
}