Skip to content

Instantly share code, notes, and snippets.

@fmpwizard
Created July 13, 2011 04:36
Show Gist options
  • Select an option

  • Save fmpwizard/1079726 to your computer and use it in GitHub Desktop.

Select an option

Save fmpwizard/1079726 to your computer and use it in GitHub Desktop.
def updateCity(x: Any) : JsCmd = {
val (cometName: String, cityId) = Full(x).asA[Map[String, Any]] match {
case Full(m) => (
m.get("cometName").getOrElse("No comet Name"),
m.get("cityId").getOrElse("1")
)
case _ => ("No Comet Name", "1")
}
...
}
@ccmtaylor
Copy link

or even

def updateCity(x: Any) : JsCmd = {
    val (cometName: String, cityId) = Full(x).asA[Map[String, Any]].map { m =>
      (
        m.get("cometName").getOrElse("No comet Name"),
        m.get("cityId").getOrElse("1")
      )
    } openOr ("No Comet Name", "1")
...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment