by kaba0 · 3y ago · 0 comments
val num = words.count(!_.isEmpty()) val num = words.count(word => word.nonEmpty)
The "bird droppings" (particularly the clever uses of _ found across Scala) were hard for me to grasp when I first started working in the language. Now they're second nature, but I try to remain cognizant of future maintainers who may be coming in to make contributions or bug fixes without first marinating in the language. val num = words.count(_.nonEmpty)