Lets say val a = List[List[int]]: What is the cleanest way to find the list that contains the most amount of elements in Scala?
Lets say val a = List[List[int]]: What is the cleanest way to find the list that contains the most amount of elements in Scala?
Try one of .maxBy or .maxByOption
List(List(0)).maxBy(_.size) // List(0)
List(List(0)).maxByOption(_.size) // Some(List(0))
List.empty[List[Int]].maxByOption(_.size) // None