0

So I have a Sequence of Ints representing notes on a guitar, now since this guitar will have 6 strings, I also have a function parameter that takes 6 Ints in a tuple like this:

pos: (Int, Int, Int, Int, Int, Int)

After have looked for "Scala seq to tuple" on Google and having found nothing useful I ask here.

How do I pass my Seq[Int] as a tuple into my function parameter most effectively?

Tarmiac
  • 846
  • 1
  • 8
  • 14
  • @voila17 Yes, specifically this one: https://stackoverflow.com/questions/14722860/convert-a-scala-list-to-a-tuple/18426026#18426026 – Tarmiac Dec 09 '21 at 18:26

1 Answers1

1

Can you avoid the Seq in the first place and have a Tuple since the very beginning?

If not, the best you can do is pattern match the Seq

seq match {
  case Seq(n1, n2, n3, n4, n5, n6) => Some(f((n1, n2, n3, n4, n5, n6)))
  case _ => None
}