Scala - 预期的标识符,但'=>'发现

时间:2016-11-11 12:37:52

标签: scala playframework

我正在一个播放scala应用程序中编写一个端点,该应用程序发出请求,在trackalbumartist类型中进行搜索。我想完成它们并将字符串转换为Future的调用。

这是我的代码:

def index = Action.async { implicit request =>
  val futures = List("track", "album", "artist")
    .map { type => performSearch("q" -> param(request, "q"), "type" -> type) }

  Future.sequence(futures).onComplete {
    Ok
  }
}

private def performSearch(criteria: (String, String)): Future = {
  ws.url("https://api.spotify.com/v1/search")
    .withQueryString(criteria)
    .get()
}

private def param(request: Request[AnyContent], name: String): String = {
  request.queryString.get(name).flatMap(_.headOption).getOrElse("")
}

但是我的地图中出现错误:

identifier expected but '=>' found // .map { type => performSearch("q" -> param(request, "q"), "type" -> type) }

1 个答案:

答案 0 :(得分:2)

LoginViewController是一个关键字。选择其他东西或将其放入`:

type