The following snippet works fine to split a number into its digits, but it’s too long:
val digits = (num toString).toList map(_.toString) map(_.toInt)
I maped them toString to get the actual value when applied toInt and not the Int value representing the Char returned by toList.
I’m new to Scala, I’m not used to the scala’s expresive style.
Is there a shorter way do this.
1 Answer