scala - How to get String value from the List that QueryString returns? -



scala - How to get String value from the List that QueryString returns? -

newbie question on play!/scala: how string stored in result?

object app extends application { def route = { case get(path("/feed/geocodeo")) & querystring(qs) => action{ request=> val result = querystring(qs,"latlng").getorelse("40.714224,-73.961452") val response = ws.url("http://maps.googleapis.com/maps/api/geocode/json?latlng="+result.tostring+"&sensor=false").get() val body = response.value.get.body ok(body).as("text/html") } } }

if querystring returns list[string], code shouldn't compile.

scala> list("hi","bye").getorelse("whatever") <console>:8: error: value getorelse not fellow member of list[java.lang.string] list("hi","bye").getorelse("whatever") ^

does code compile? if so, querystring has getorelse method, , result specific superclass of string , whatever returned querystring.

usually you'd phone call getorelse on option[something], , object passed getorelse should have same type something or else you're going object type isn't going useful.

scala playframework

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -