[Solved] Scala Filter Only Digits


I think this might solve your problem

t.countByValue().filter(tupleOfCount=>Try(tupleOfCount._1.toInt).toOption.isEmpty).print()

Use of isInstanceOf should be the last resort as @sergey said , so this code must solve the issue or else the pattern matching would be a good option too.

solved Scala Filter Only Digits