lserlohn
lserlohn

Reputation: 6216

How to split a list by its element in Scala

I have a List / Seq looks like:

case class elmt(id:Int, value:Int)

val myinput = Seq(elmt(1,10), elmt(2,11), elmt(3,12))

I want to split the list to get:

l1 = (1,2,3)
l2 = (10,11,12)

How can I implement the split function? thanks,

Upvotes: 1

Views: 47

Answers (1)

lserlohn
lserlohn

Reputation: 6216

I figured it out by myself

myinput.unzip(x=>(x.id,x.value))

Upvotes: 2

Related Questions