Skip to content

Instantly share code, notes, and snippets.

@cheleb
Created March 23, 2014 12:45
Show Gist options
  • Save cheleb/9722598 to your computer and use it in GitHub Desktop.
Save cheleb/9722598 to your computer and use it in GitHub Desktop.
//Avec pattern matching
get("/track/:id") { request =>
val result = request.routeParams.getOrElse("id") match {
case None => Map("track2" -> "larzac", "track1" -> "salagou")
case Some(id) => Map("track1" -> "salagou")
}
render.json(result)
}
//Sans pattern matching
render.json(o.map(id => Map("track1" -> "salagou")).getOrElse(Map("track2" -> "larzac", "track1" -> "salagou")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment