scala assigning string and array of values -
i'm trying assign string followed array of scores.
i defined categories
case class categoryscore( //define category score class val food: int, val tech: int, val service: int, val fashion: int) and mapped them keys string such name of product followed case class of scores.
var keywordscores:map[string, categoryscore] = map() //keyword scores keywordscores += ("amazon",categoryscore(1,9,1,4)) //tried add score string, not work am missing here?
scala> keywordscores += ("amazon" -> categoryscore(1,9,1,4)) or (note parenthesis)
scala> keywordscores += (("amazon", categoryscore(1,9,1,4))) the reason + defined +(kvs: (a, b)*): map[a, b], meaning can take number of (key,value) pairs, leading += (k,v) being ambiguous.
the a -> b notation removes ambiguity (and it's nicer read).
Comments
Post a Comment