Strings In Depth18 / 19
Up next

Count words

@main def main(): Unit =
  val text = "the quick brown fox"
  // split on runs of whitespace, then count
  val n = text.split("\\s+").length
  println(n)
What you're solving

split on whitespace and count