Skip to content

Instantly share code, notes, and snippets.

@JohnFord
Created September 2, 2014 18:45
Show Gist options
  • Save JohnFord/48c701741417476e2eca to your computer and use it in GitHub Desktop.
Save JohnFord/48c701741417476e2eca to your computer and use it in GitHub Desktop.
Unzip a list of List[List[Any]]?
import scala.collection.mutable.ListBuffer
val diffs: ListBuffer[List[Any]] = new ListBuffer[List[Any]]()
diffs.append(List("field1", 1, 2))
diffs.append(List("field2", 3, 4))
diffs.append(List("field3", 5, 6))
/* At this point, I'd like to do something like: diffs.toList.unzip and wind up with List("field1", "field2", "field3"), List((1,2), (3,4), (5,6))
But that thows an exception: "error: No implicit view available from List[Any] => (A1, A2)." */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment