Skip to content

Instantly share code, notes, and snippets.

@tommilimmot
Last active December 7, 2017 21:00
Show Gist options
  • Save tommilimmot/6102487 to your computer and use it in GitHub Desktop.
Save tommilimmot/6102487 to your computer and use it in GitHub Desktop.
scala: pass List/Collection of arguments to Function with argument type (String, String) *, such as play.api.libs.ws.WS.WSRequestHolder.withQueryString()
val argumentList = List("arg1"->"val1", "arg2"->"val2", "arg3"->"val3")
// repl> argumentList: List[(String, String)] = List((arg1,val1), (arg2,val2), (arg3,val3))
// from play 2.1 scala api
// def withQueryString(parameters: (String, String)*): WSRequestHolder
// can't pass List[(String, String)] to function because it expects type (String, String)
// unwrap collection (List) with : _*
play.api.libs.ws.WS.url("http://localhost").withQueryString(argumentList : _*).get
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment