1

I want to have a method that builds up query parameters for def withQueryString(parameters: (String, String)*): WSRequest. In particular, I have the following method:

def toParams: Seq[(String, String)] = {
  val params = List(
    ("firstName" -> "john"),
    ("lastName" -> "doe"),
    ("age" -> "35"),
    ("ssnr" -> "1234")
  )
  params
}

The problem is that the method withQueryString requires (String, String)* instead of Seq[(String, String)]. How can I make this conversion?

Yuval Itzchakov
  • 146,575
  • 32
  • 257
  • 321
John Doe
  • 277
  • 3
  • 14
  • 1
    Possible duplicate of [How to pass scala Array into scala vararg method?](http://stackoverflow.com/questions/31064753/how-to-pass-scala-array-into-scala-vararg-method) – Tzach Zohar Oct 09 '16 at 07:36

1 Answers1

3

You can unpack the Seq using :_*:

val result = withQueryString(toParams: _*)
Yuval Itzchakov
  • 146,575
  • 32
  • 257
  • 321