Im trying to add items to a ListBuffer (or any other structure ?) basically i'm trying to create a list of PostMD objects by using this method.
def getData(url: String, userID: String): ListBuffer[PostMD] = {
val chunk: JsValue = BusinessLogic.Methods.getJsonValue(url)
val postMd: List[PostMD] = for {
x <- (chunk \ "data").as[List[JsValue]]
} yield x.as[PostMD]
val filtered: ListBuffer[PostMD] =
postMd.filter(_.fromID == userID).to[ListBuffer])
if ((chunk \ "paging" \ "next").toString() != null)
getData(chunk.\("paging").\("next").toString(), userID)
return filtered
}
Obviously im doing something wrong... what will be the best way to add item to a list inside a recursive method ?
thanks
miki