You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I know the title sounds confusing but hopefully my explanation will be clearer. This is based on this post which I resolved. However I had a second thought and I figured that this would be better done using group-by function! Its not going to save us much lines of code but it would probably look cleaner.
Going through the exercise I encountered strange error. lets assume for now that the end result will be an array of of objects, here is the spec which wont compile:
Running the above will give me the scariest error of all :
com.schibsted.spt.data.jslt.JsltException: Parse error: Encountered " "for" "for "" at line 10, column 2 ....
...
However if I store the array def in a variable and return the variable as in the below it works!!
let result = [for (exp:group-by(., .name, {.date:.height})) {.key: collapse-objects(.values)} ]
$result
My question why is that? am I missing something or is the parser not able to tell the end of the function from what is being returned?
By the way if I change the result from being an array to complex object - which is what is expected in the post - it works too without having to declare a variable !!
Hi,
I know the title sounds confusing but hopefully my explanation will be clearer. This is based on this post which I resolved. However I had a second thought and I figured that this would be better done using group-by function! Its not going to save us much lines of code but it would probably look cleaner.
Going through the exercise I encountered strange error. lets assume for now that the end result will be an array of of objects, here is the spec which wont compile:
Running the above will give me the scariest error of all :
However if I store the array def in a variable and return the variable as in the below it works!!
My question why is that? am I missing something or is the parser not able to tell the end of the function from what is being returned?
By the way if I change the result from being an array to complex object - which is what is expected in the post - it works too without having to declare a variable !!
{for (exp:group-by(., .name, {.date:.height})) .key: collapse-objects(.values)}
The text was updated successfully, but these errors were encountered: