KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm just starting out in Scala. I find myself using tuple variables a lot. For example, here's some code I wrote: /* Count each letter of a string and return in a list sorted by character * countLetter("test") = List(('e',1),('s',1),('t',2)) */ def countLetters(s: String): List[(Char, Int)] = { val charsListMap = s.toList.groupBy((c:Char) => c) charsListMap.map(x => (x._1, x._2.length)).toList.sortBy(_._1) } Is this tuple syntax (x._1, x._2 etc) frowned upon by Scala developers?
Tags (comma-separated)
Save Edits
Cancel