以下のコードは例外をスローしています:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at line (s(0).toString,s(0).toString)
この例外をキャッチして、マップ機能を次のアイテムに続行したいと思います。例外を無視して残りの関数を続行するには、より高次の関数を try/catch で囲みます: groupBy & mapValues ?
println(toIterate.toList.map(s => (s(0).toString,s(0).toString))
.groupBy(_._1)
.mapValues(_.map(_._2)))