scala - Difference between concatenation of anys in map versus function -


i've got array of elements of type any. i'm using values concatenate them string in 1 line inside map declaration:

val maprequest = map(     "the_geom" -> "cdb_latlng(" + row(2).tostring() + ", " + row(3).tostring() + ")" ) 

this gives me error don't understand:

[error] /path/to/file/signal.scala:92: type mismatch; [error]  found   : string [error]  required: (?, ?) 

when put concatenation inside function , use this:

val maprequest = map(     "the_geom" -> utils.getgeom(row(2), row(3)) ) 

where function getgeom defined this:

def getgeom(lat:any, lon:any) : string = {     return "cdb_latlng(" + lat.tostring() + ", " + lon.tostring() + ")" } 

everything works.

can explain different have expression of concatenation inside map declaration vs function declaration?

this work:

map(   "the_geom" -> ("cdb_latlng(" + row(2).tostring() + ", " + row(3).tostring() + ")") ) 

you trying instanciate map tuple "the_geom" -> "cdb_latlng(" concatenated string, because of synthetic function +, assume both sides being represented string, if not otherwise specified. function scope of getgeom provides scope you, saving parantheses. if wrap string concatenation in parentheses, value within evaluated before tuple operation. in case, read left right, , makes sense.


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -